still footbar can not draw
7
Menu/GameShell/20_Retro Games/MAME/action.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ROM=/home/cpi/games/MAME
|
||||||
|
ROM_SO=/home/cpi/apps/emulators/mame2003_plus_libretro.so
|
||||||
|
EXT=zip
|
||||||
|
LAUNCHER=retroarch -L
|
||||||
|
TITLE=MAME Roms
|
||||||
|
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mame2003_plus_libretro.so.zip
|
||||||
|
RETRO_CONFIG=/home/cpi/apps/launcher/Menu/GameShell/20_Retro\ Games/MAME/retroarch.cfg
|
||||||
111
Menu/GameShell/20_Retro Games/MAME/retroarch-core-options.cfg
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
mame2003-plus_frameskip = "0"
|
||||||
|
mame2003-plus_input_interface = "retropad"
|
||||||
|
mame2003-plus_retropad_layout = "modern"
|
||||||
|
mame2003-plus_mouse_device = "mouse"
|
||||||
|
mame2003-plus_crosshair_enabled = "enabled"
|
||||||
|
mame2003-plus_display_setup = "disabled"
|
||||||
|
mame2003-plus_enable_backdrop = "disabled"
|
||||||
|
mame2003-plus_bios_region = "default"
|
||||||
|
mame2003-plus_dialsharexy = "disabled"
|
||||||
|
mame2003-plus_rstick_to_btns = "enabled"
|
||||||
|
mame2003-plus_tate_mode = "disabled"
|
||||||
|
mame2003-plus_vector_resolution_multiplier = "1"
|
||||||
|
mame2003-plus_vector_antialias = "disabled"
|
||||||
|
mame2003-plus_vector_translucency = "enabled"
|
||||||
|
mame2003-plus_vector_beam_width = "1"
|
||||||
|
mame2003-plus_vector_flicker = "20"
|
||||||
|
mame2003-plus_vector_intensity = "1.5"
|
||||||
|
mame2003-plus_skip_rom_verify = "disabled"
|
||||||
|
mame2003-plus_external_hiscore = "disabled"
|
||||||
|
mame2003-plus_sample_rate = "48000"
|
||||||
|
mame2003-plus_dcs_speedhack = "enabled"
|
||||||
|
mame2003-plus_skip_disclaimer = "enabled"
|
||||||
|
mame2003-plus_skip_warnings = "disabled"
|
||||||
|
mgba_solar_sensor_level = "0"
|
||||||
|
mgba_allow_opposing_directions = "OFF"
|
||||||
|
mgba_gb_model = "Autodetect"
|
||||||
|
mgba_use_bios = "ON"
|
||||||
|
mgba_skip_bios = "OFF"
|
||||||
|
mgba_sgb_borders = "ON"
|
||||||
|
mgba_idle_optimization = "Remove Known"
|
||||||
|
mgba_frameskip = "0"
|
||||||
|
vbanext_bios = "enabled"
|
||||||
|
mame_current_mouse_enable = "enabled"
|
||||||
|
mame_current_videoapproach1_enable = "disabled"
|
||||||
|
mame_current_skip_nagscreen = "enabled"
|
||||||
|
mame_current_skip_gameinfo = "disabled"
|
||||||
|
mame_current_skip_warnings = "disabled"
|
||||||
|
mame_current_aspect_ratio = "DAR"
|
||||||
|
mame_current_turbo_button = "disabled"
|
||||||
|
mame_current_turbo_delay = "medium"
|
||||||
|
mame_current_frame_skip = "0"
|
||||||
|
mame_current_sample_rate = "48000Hz"
|
||||||
|
mame_current_adj_brightness = "default"
|
||||||
|
mame_current_adj_contrast = "default"
|
||||||
|
mame_current_adj_gamma = "default"
|
||||||
|
mame-external_hiscore = "disabled"
|
||||||
|
vbam_layer_1 = "Yes"
|
||||||
|
vbam_layer_2 = "Yes"
|
||||||
|
vbam_layer_3 = "Yes"
|
||||||
|
vbam_layer_4 = "Yes"
|
||||||
|
vbam_layer_5 = "Yes"
|
||||||
|
vbam_layer_6 = "Yes"
|
||||||
|
vbam_layer_7 = "Yes"
|
||||||
|
vbam_layer_8 = "Yes"
|
||||||
|
snes9x_next_overclock = "disabled"
|
||||||
|
beetle_psx_cdimagecache = "disabled"
|
||||||
|
beetle_psx_widescreen_hack = "disabled"
|
||||||
|
beetle_psx_widescreen_auto_ar = "disabled"
|
||||||
|
beetle_psx_use_mednafen_memcard0_method = "libretro"
|
||||||
|
beetle_psx_shared_memory_cards = "disabled"
|
||||||
|
beetle_psx_experimental_save_states = "disabled"
|
||||||
|
beetle_psx_initial_scanline = "0"
|
||||||
|
beetle_psx_initial_scanline_pal = "0"
|
||||||
|
beetle_psx_last_scanline = "239"
|
||||||
|
beetle_psx_last_scanline_pal = "287"
|
||||||
|
beetle_psx_analog_toggle = "disabled"
|
||||||
|
beetle_psx_enable_multitap_port1 = "disabled"
|
||||||
|
beetle_psx_enable_multitap_port2 = "disabled"
|
||||||
|
fceumm_region = "Auto"
|
||||||
|
fceumm_aspect = "8:7 PAR"
|
||||||
|
fceumm_palette = "default"
|
||||||
|
fceumm_up_down_allowed = "disabled"
|
||||||
|
fceumm_use_ntsc = "disabled"
|
||||||
|
fceumm_overscan_h = "disabled"
|
||||||
|
fceumm_overscan_v = "enabled"
|
||||||
|
fceumm_nospritelimit = "disabled"
|
||||||
|
fceumm_sndvolume = "150"
|
||||||
|
fceumm_sndquality = "Low"
|
||||||
|
fceumm_swapduty = "disabled"
|
||||||
|
fceumm_turbo_enable = "None"
|
||||||
|
fceumm_turbo_delay = "3"
|
||||||
|
fceumm_zapper_mode = "pointer"
|
||||||
|
fceumm_show_crosshair = "enabled"
|
||||||
|
fceumm_overclocking = "disabled"
|
||||||
|
nestopia_blargg_ntsc_filter = "disabled"
|
||||||
|
nestopia_palette = "cxa2025as"
|
||||||
|
nestopia_nospritelimit = "disabled"
|
||||||
|
nestopia_overclock = "1x"
|
||||||
|
nestopia_select_adapter = "auto"
|
||||||
|
nestopia_fds_auto_insert = "enabled"
|
||||||
|
nestopia_overscan_v = "enabled"
|
||||||
|
nestopia_overscan_h = "disabled"
|
||||||
|
nestopia_aspect = "auto"
|
||||||
|
nestopia_genie_distortion = "disabled"
|
||||||
|
nestopia_favored_system = "auto"
|
||||||
|
nestopia_ram_power_state = "0x00"
|
||||||
|
nestopia_turbo_pulse = "2"
|
||||||
|
mame2003-plus_brightness = "1.0"
|
||||||
|
mame2003-plus_gamma = "1.2"
|
||||||
|
mame2003-plus_neogeo_bios = "default"
|
||||||
|
mame2003-plus_stv_bios = "default"
|
||||||
|
mame2003-plus_dual_joysticks = "disabled"
|
||||||
|
mame2003-plus_use_samples = "enabled"
|
||||||
|
mame2003-plus_nvram_bootstraps = "enabled"
|
||||||
|
mame2003-plus_retropad1_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_retropad2_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_retropad3_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_retropad4_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_retropad5_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_retropad6_layout = "Modern Gamepad"
|
||||||
|
mame2003-plus_mame_remapping = "disabled"
|
||||||
2880
Menu/GameShell/20_Retro Games/MAME/retroarch.cfg
Normal file
6
Menu/GameShell/20_Retro Games/MGBA/action.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
ROM=/home/cpi/games/MGBA
|
||||||
|
ROM_SO=/home/cpi/apps/emulators/mgba_libretro.so
|
||||||
|
EXT=gba,gbx
|
||||||
|
LAUNCHER=retroarch -L
|
||||||
|
TITLE=MGBA Roms
|
||||||
|
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mgba_libretro.so.zip
|
||||||
7
Menu/GameShell/20_Retro Games/NESTOPIA/action.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ROM=/home/cpi/games/NESTOPIA
|
||||||
|
ROM_SO=/home/cpi/apps/emulators/nestopia_libretro.so
|
||||||
|
EXT=zip
|
||||||
|
LAUNCHER=retroarch -L
|
||||||
|
TITLE=NESTOPIA Roms
|
||||||
|
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/nestopia_libretro.so.zip
|
||||||
|
|
||||||
1
Menu/GameShell/CaveStory.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
retroarch -L /home/cpi/apps/emulators/nxengine_libretro.so /home/cpi/games/nxengine/cavestory/data
|
||||||
1
Menu/GameShell/RetroArch.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
retroarch
|
||||||
1
Menu/GameShell/freeDM.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
chocolate-doom -iwad /home/cpi/games/FreeDM/freedoom1.wad
|
||||||
92
main.go
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
|
||||||
|
"os"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/display"
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
// "github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/font"
|
||||||
|
"github.com/cuu/gogame/time"
|
||||||
|
|
||||||
|
"./sysgo/UI"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func run() int {
|
||||||
|
display.Init()
|
||||||
|
font.Init()
|
||||||
|
screen := display.SetMode(int32(UI.Width),int32(UI.Height),0,32)
|
||||||
|
|
||||||
|
UI.MyIconPool.Init()
|
||||||
|
|
||||||
|
main_screen := UI.NewMainScreen()
|
||||||
|
main_screen.HWND = screen
|
||||||
|
main_screen.Init()
|
||||||
|
|
||||||
|
title_bar := UI.NewTitleBar()
|
||||||
|
foot_bar := UI.NewFootBar()
|
||||||
|
|
||||||
|
title_bar.Init(main_screen)
|
||||||
|
foot_bar.Init(main_screen)
|
||||||
|
|
||||||
|
main_screen.TitleBar = title_bar
|
||||||
|
main_screen.FootBar = foot_bar
|
||||||
|
|
||||||
|
main_screen.ReadTheDirIntoPages("Menu",0,nil)
|
||||||
|
main_screen.FartherPages()
|
||||||
|
|
||||||
|
main_screen.Draw()
|
||||||
|
main_screen.SwapAndShow()
|
||||||
|
|
||||||
|
UI.SwapAndShow()
|
||||||
|
|
||||||
|
fmt.Println(main_screen)
|
||||||
|
|
||||||
|
running := true
|
||||||
|
for running {
|
||||||
|
ev := event.Wait()
|
||||||
|
if ev.Type == event.QUIT {
|
||||||
|
running = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if ev.Type == event.USEREVENT {
|
||||||
|
|
||||||
|
fmt.Println(ev.Data["Msg"])
|
||||||
|
}
|
||||||
|
if ev.Type == event.KEYDOWN {
|
||||||
|
fmt.Println(ev)
|
||||||
|
if ev.Data["Key"] == "Q" {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if ev.Data["Key"] == "Escape" {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if ev.Data["Key"] == "T" {
|
||||||
|
time.Delay(1000)
|
||||||
|
}
|
||||||
|
if ev.Data["Key"] == "P" {
|
||||||
|
event.Post(event.RUNEVT,"GODEBUG=cgocheck=0 sucks") // just id and string, simpify the stuff
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
var exitcode int
|
||||||
|
|
||||||
|
os.Setenv("SDL_VIDEO_CENTERED","1")
|
||||||
|
|
||||||
|
sdl.Main(func() {
|
||||||
|
exitcode = run()
|
||||||
|
})
|
||||||
|
|
||||||
|
os.Exit(exitcode)
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 286 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 427 B After Width: | Height: | Size: 427 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
|
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 627 B |
@ -1,6 +1,8 @@
|
|||||||
package DBUS
|
package DBUS
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
package UI
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ var Fonts map[string]*ttf.Font
|
|||||||
func init() {
|
func init() {
|
||||||
font.Init()
|
font.Init()
|
||||||
|
|
||||||
skinpath := "../skin/"+sysgo.SKIN+"/truetype"
|
skinpath := "skin/"+sysgo.SKIN+"/truetype"
|
||||||
|
|
||||||
Fonts = make(map[string]*ttf.Font)
|
Fonts = make(map[string]*ttf.Font)
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
// "io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
"github.com/cuu/gogame/rect"
|
"github.com/cuu/gogame/rect"
|
||||||
"github.com/cuu/gogame/surface"
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/gogame/image"
|
||||||
|
"github.com/cuu/gogame/font"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,6 +69,7 @@ type FootBar struct {
|
|||||||
LabelFont *ttf.Font
|
LabelFont *ttf.Font
|
||||||
State string
|
State string
|
||||||
SkinManager *SkinManager
|
SkinManager *SkinManager
|
||||||
|
|
||||||
icon_base_path string
|
icon_base_path string
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -93,13 +101,7 @@ func (self *FootBar) ReadFootBarIcons( icondir string) {
|
|||||||
}
|
}
|
||||||
keynames := [5]string{"nav","x","y","a","b"}
|
keynames := [5]string{"nav","x","y","a","b"}
|
||||||
|
|
||||||
share_surf := image.Load(icon_base_path+"footbar.png")
|
share_surf := image.Load(self.icon_base_path+"footbar.png")
|
||||||
|
|
||||||
files,err := ioutil.ReadDir(icondir)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for i,v := range keynames { // share_surf contains same number of image pieces of keynames
|
for i,v := range keynames { // share_surf contains same number of image pieces of keynames
|
||||||
it := NewFootBarIconItem()
|
it := NewFootBarIconItem()
|
||||||
@ -119,8 +121,6 @@ func (self *FootBar) Init(main_screen *MainScreen) {
|
|||||||
self.CanvasHWND = surface.Surface(self.Width,self.Height)
|
self.CanvasHWND = surface.Surface(self.Width,self.Height)
|
||||||
self.HWND = main_screen.HWND
|
self.HWND = main_screen.HWND
|
||||||
self.SkinManager = main_screen.SkinManager
|
self.SkinManager = main_screen.SkinManager
|
||||||
self.DBusManager = main_screen.DBusManager
|
|
||||||
|
|
||||||
|
|
||||||
round_corners := NewFootBarIconItem()
|
round_corners := NewFootBarIconItem()
|
||||||
round_corners.IconWidth = 10
|
round_corners.IconWidth = 10
|
||||||
@ -128,7 +128,7 @@ func (self *FootBar) Init(main_screen *MainScreen) {
|
|||||||
|
|
||||||
round_corners.MyType = ICON_TYPES["STAT"]
|
round_corners.MyType = ICON_TYPES["STAT"]
|
||||||
round_corners.Parent = self
|
round_corners.Parent = self
|
||||||
round_corners.ImgSurf = MyIconPool.GetImageSurf["roundcorners"]
|
round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
|
||||||
round_corners.Adjust(0,0,10,10,0)
|
round_corners.Adjust(0,0,10,10,0)
|
||||||
|
|
||||||
self.Icons["round_corners"] = round_corners
|
self.Icons["round_corners"] = round_corners
|
||||||
@ -136,14 +136,15 @@ func (self *FootBar) Init(main_screen *MainScreen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *FootBar) ResetNavText() {
|
func (self *FootBar) ResetNavText() {
|
||||||
self.Icons["nav"].Label.SetText("Nav.")
|
self.Icons["nav"].SetLabelText("Nav.")
|
||||||
self.State = "normal"
|
self.State = "normal"
|
||||||
self.Draw()
|
self.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *FootBar) UpdateNavText(texts string) {
|
func (self *FootBar) UpdateNavText(texts string) {
|
||||||
self.State = "tips"
|
self.State = "tips"
|
||||||
my_text := font.Render(self.LabelFont, texts, true,self.SkinManager.GiveColor("Text"))
|
|
||||||
|
// my_text := font.Render(self.LabelFont, texts, true,self.SkinManager.GiveColor("Text"),nil)
|
||||||
|
|
||||||
left_width := self.Width - 18
|
left_width := self.Width - 18
|
||||||
|
|
||||||
@ -151,21 +152,21 @@ func (self *FootBar) UpdateNavText(texts string) {
|
|||||||
|
|
||||||
for i,_ := range texts {
|
for i,_ := range texts {
|
||||||
text_ := texts[:i+1]
|
text_ := texts[:i+1]
|
||||||
my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"))
|
my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"),nil)
|
||||||
final_piece = text_
|
final_piece = text_
|
||||||
if my_text.W >= left_width {
|
if int(my_text.W) >= left_width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("finalpiece %s\n", final_piece)
|
fmt.Printf("finalpiece %s\n", final_piece)
|
||||||
|
|
||||||
self.Icons["nav"].Label.SetText(final_piece)
|
self.Icons["nav"].SetLabelText(final_piece)
|
||||||
self.Draw()
|
self.Draw()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *FootBar) SetLabelTexts( texts []string) {
|
func (self *FootBar) SetLabelTexts( texts [5]string) {
|
||||||
keynames := [5]string{"nav","x","y","a","b"}
|
keynames := [5]string{"nav","x","y","a","b"}
|
||||||
if len(texts) < 5 {
|
if len(texts) < 5 {
|
||||||
log.Fatal("SetLabelTexts texts length error")
|
log.Fatal("SetLabelTexts texts length error")
|
||||||
@ -173,7 +174,7 @@ func (self *FootBar) SetLabelTexts( texts []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for idx,x := range keynames {
|
for idx,x := range keynames {
|
||||||
self.Icons[x].Label.SetText(texts[idx])
|
self.Icons[x].SetLabelText(texts[idx])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -202,7 +203,7 @@ func (self *FootBar) Draw() {
|
|||||||
_w := 0
|
_w := 0
|
||||||
|
|
||||||
for i,x := range []string{"b","a","y","x"} {
|
for i,x := range []string{"b","a","y","x"} {
|
||||||
if self.Icons[x].Label.GetText() != "" {
|
if self.Icons[x].GetLabelText() != "" {
|
||||||
if i== 0 {
|
if i== 0 {
|
||||||
_w += self.Icons[x].TotalWidth()
|
_w += self.Icons[x].TotalWidth()
|
||||||
}else {
|
}else {
|
||||||
@ -215,11 +216,12 @@ func (self *FootBar) Draw() {
|
|||||||
self.Icons[x].Draw()
|
self.Icons[x].Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
draw.Line(self.CanvasHWND, self.SkinManager.GiveColor("Line"),0,0,Width,0,self.BorderWidth)
|
|
||||||
|
draw.Line(self.CanvasHWND, self.SkinManager.GiveColor("Line"),0,0,Width,0,self.BorderWidth)
|
||||||
if self.HWND != nil {
|
|
||||||
rect_ := rect.Rect(self.PosX, Height - self.Height, Width, self.BarHeight)
|
if self.HWND != nil {
|
||||||
surface.Blit(self.HWND,self.CanvasHWND, &rect_,nil)
|
rect_ := rect.Rect(self.PosX, Height - self.Height, Width, self.BarHeight)
|
||||||
}
|
surface.Blit(self.HWND,self.CanvasHWND, &rect_,nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,10 @@ import (
|
|||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/image"
|
||||||
"github.com/cuu/gogame/transform"
|
"github.com/cuu/gogame/transform"
|
||||||
"github.com/cuu/gogame/utils"
|
"github.com/cuu/gogame/utils"
|
||||||
)
|
)
|
||||||
@ -27,20 +31,29 @@ type IconItemInterface interface {
|
|||||||
SetParent( p interface{} )
|
SetParent( p interface{} )
|
||||||
|
|
||||||
SetLabelColor(col *color.Color)
|
SetLabelColor(col *color.Color)
|
||||||
|
SetLabelText(text string)
|
||||||
|
GetLabelText() string
|
||||||
|
|
||||||
Coord() (int,int)
|
Coord() (int,int)
|
||||||
NewCoord(x,y int)
|
NewCoord(x,y int)
|
||||||
|
|
||||||
TotalWidth() int
|
TotalWidth() int
|
||||||
Size() (int,int)
|
Size() (int,int)
|
||||||
|
|
||||||
|
|
||||||
AddLabel(text string, fontobj *ttf.Font)
|
AddLabel(text string, fontobj *ttf.Font)
|
||||||
GetLinkPage() PageInterface
|
GetLinkPage() PageInterface
|
||||||
AdjustLinkPage()
|
AdjustLinkPage()
|
||||||
GetImageSurf() *sdl.Surface
|
GetImgSurf() *sdl.Surface
|
||||||
SetImageSurf(newsurf *sdl.Surface)
|
SetImgSurf(newsurf *sdl.Surface)
|
||||||
CreateImageSurf()
|
CreateImgSurf()
|
||||||
ChangeImgSurfColor(col *color.Color)
|
ChangeImgSurfColor(col *color.Color)
|
||||||
|
|
||||||
|
Clear()
|
||||||
|
|
||||||
|
GetCmdInvoke() PluginInterface
|
||||||
|
|
||||||
|
|
||||||
Draw()
|
Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +99,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
|
|||||||
self.AnimationTime = at
|
self.AnimationTime = at
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) Init(x,y,w,h,at int) {
|
func (self *IconItem) Adjust(x,y,w,h,at int) {
|
||||||
self.PosX = x
|
self.PosX = x
|
||||||
self.PosY = y
|
self.PosY = y
|
||||||
self.Width = w
|
self.Width = w
|
||||||
@ -97,7 +110,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
|
|||||||
self.Label.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
self.Label.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||||
}
|
}
|
||||||
|
|
||||||
self.CreateImageSurf()
|
self.CreateImgSurf()
|
||||||
self.AdjustLinkPage()
|
self.AdjustLinkPage()
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -136,13 +149,21 @@ func (self *IconItem) SetIndex(i int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) SetParent(p interface{} ) {
|
func (self *IconItem) SetParent(p interface{} ) {
|
||||||
self.Parent = p
|
self.Parent = p.(PageInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) SetLabelColor(col *color.Color) {
|
func (self *IconItem) SetLabelColor(col *color.Color) {
|
||||||
self.Label.SetColor(col)
|
self.Label.SetColor(col)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *IconItem) GetLabelText() string {
|
||||||
|
return self.Label.GetText()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *IconItem) SetLabelText(text string) {
|
||||||
|
self.Label.SetText(text)
|
||||||
|
}
|
||||||
|
|
||||||
func (self *IconItem) Coord() (int,int) {
|
func (self *IconItem) Coord() (int,int) {
|
||||||
return self.PosX,self.PosY
|
return self.PosX,self.PosY
|
||||||
}
|
}
|
||||||
@ -153,7 +174,7 @@ func (self *IconItem) NewCoord(x,y int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) TotalWidth() int {
|
func (self *IconItem) TotalWidth() int {
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) Size() (int,int) {
|
func (self *IconItem) Size() (int,int) {
|
||||||
@ -165,7 +186,7 @@ func (self *IconItem) AddLabel(text string, fontobj *ttf.Font) {
|
|||||||
l:= NewLabel()
|
l:= NewLabel()
|
||||||
self.Label = l
|
self.Label = l
|
||||||
}else {
|
}else {
|
||||||
self.Label.Init(text,fontobj)
|
self.Label.Init(text,fontobj,nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +198,7 @@ func (self *IconItem) AdjustLinkPage() {
|
|||||||
if self.MyType == ICON_TYPES["DIR"] && self.LinkPage != nil {
|
if self.MyType == ICON_TYPES["DIR"] && self.LinkPage != nil {
|
||||||
self.LinkPage.SetIndex(0)
|
self.LinkPage.SetIndex(0)
|
||||||
self.LinkPage.SetAlign(ALIGN["SLeft"])
|
self.LinkPage.SetAlign(ALIGN["SLeft"])
|
||||||
self.LinkPage.SetIconNumbers( len(self.LinkPage.GetIcons()) )
|
self.LinkPage.UpdateIconNumbers()
|
||||||
self.LinkPage.SetScreen(self.Parent.GetScreen())
|
self.LinkPage.SetScreen(self.Parent.GetScreen())
|
||||||
self.LinkPage.SetCanvasHWND( (self.Parent.GetScreen()).CanvasHWND )
|
self.LinkPage.SetCanvasHWND( (self.Parent.GetScreen()).CanvasHWND )
|
||||||
self.LinkPage.SetFootMsg([5]string{ "Nav.","","","Back","Enter" } )
|
self.LinkPage.SetFootMsg([5]string{ "Nav.","","","Back","Enter" } )
|
||||||
@ -194,19 +215,19 @@ func (self *IconItem) AdjustLinkPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *IconItem) GetImageSurf() *sdl.Surface {
|
func (self *IconItem) GetImgSurf() *sdl.Surface {
|
||||||
return self.ImgSurf
|
return self.ImgSurf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconItem) SetImageSurf(newsurf *sdl.Surface) {
|
func (self *IconItem) SetImgSurf(newsurf *sdl.Surface) {
|
||||||
self.ImgSurf = newsurf
|
self.ImgSurf = newsurf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (self *IconItem) CreateImageSurf() {
|
func (self *IconItem) CreateImgSurf() {
|
||||||
if self.ImgSurf == nil && self.ImageName != "" {
|
if self.ImgSurf == nil && self.ImageName != "" {
|
||||||
self.ImgSurf = image.Load(self.ImageName)
|
self.ImgSurf = image.Load(self.ImageName)
|
||||||
if self.ImgSurf.W > IconWidth || self.ImgSurf.H > IconHeight {
|
if int(self.ImgSurf.W) > IconWidth || int(self.ImgSurf.H) > IconHeight {
|
||||||
self.ImgSurf = transform.Scale(self.ImgSurf,IconWidth,IconHeight)
|
self.ImgSurf = transform.Scale(self.ImgSurf,IconWidth,IconHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,12 +237,20 @@ func (self *IconItem) ChangeImgSurfColor(col *color.Color) {
|
|||||||
utils.ColorSurface(self.ImgSurf,col)
|
utils.ColorSurface(self.ImgSurf,col)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *IconItem) Clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *IconItem) GetCmdInvoke() PluginInterface {
|
||||||
|
return self.CmdInvoke
|
||||||
|
}
|
||||||
|
|
||||||
func (self *IconItem) Draw() {
|
func (self *IconItem) Draw() {
|
||||||
|
|
||||||
parent_x,parent_y := self.Parent.Coord()
|
parent_x,parent_y := self.Parent.Coord()
|
||||||
|
|
||||||
if self.Label != nil {
|
if self.Label != nil {
|
||||||
lab_x,lab_y := self.Label.Coord()
|
// lab_x,lab_y := self.Label.Coord()
|
||||||
lab_w,lab_h:= self.Label.Size()
|
lab_w,lab_h:= self.Label.Size()
|
||||||
|
|
||||||
if self.Align == ALIGN["VCenter"] {
|
if self.Align == ALIGN["VCenter"] {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ func (self *IconPool) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *IconPool) GetImgSurf(keyname string) *sdl.Surface {
|
func (self *IconPool) GetImgSurf(keyname string) *sdl.Surface {
|
||||||
if val,ok := self.Icons[keyname]; ok {
|
if _,ok := self.Icons[keyname]; ok {
|
||||||
return self.Icons[keyname]
|
return self.Icons[keyname]
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"../sysgo"
|
"../../sysgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,18 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
"github.com/cuu/gogame/color"
|
"github.com/cuu/gogame/color"
|
||||||
"github.com/cuu/gogame/font"
|
"github.com/cuu/gogame/font"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LabelInterface interface {
|
type LabelInterface interface {
|
||||||
Init( text string, font_obj *ttf.Font,col *color.Color )
|
Init( text string, font_obj *ttf.Font,col *color.Color )
|
||||||
|
SetCanvasHWND( canvas *sdl.Surface)
|
||||||
Coord() (int,int)
|
Coord() (int,int)
|
||||||
Size() (int,int)
|
Size() (int,int)
|
||||||
NewCoord(x,y int)
|
NewCoord(x,y int)
|
||||||
@ -31,7 +34,7 @@ type Label struct {
|
|||||||
// TextSurf *sdl.Surface
|
// TextSurf *sdl.Surface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLabel() *Label() {
|
func NewLabel() *Label {
|
||||||
l := &Label{}
|
l := &Label{}
|
||||||
l.Color = &color.Color{83,83,83,255}
|
l.Color = &color.Color{83,83,83,255}
|
||||||
return l
|
return l
|
||||||
@ -51,6 +54,10 @@ func (self *Label) Init(text string, font_obj *ttf.Font,col *color.Color ) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Label) SetCanvasHWND( canvas *sdl.Surface) {
|
||||||
|
self.CanvasHWND = canvas
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Label) Coord() (int,int) {
|
func (self *Label) Coord() (int,int) {
|
||||||
return self.PosX,self.PosY
|
return self.PosX,self.PosY
|
||||||
}
|
}
|
||||||
@ -85,8 +92,8 @@ func (self *Label) Draw() {
|
|||||||
font.SetBold(self.FontObj,false) // avoing same font tangling set_bold to others
|
font.SetBold(self.FontObj,false) // avoing same font tangling set_bold to others
|
||||||
my_text := font.Render(self.FontObj,self.Text, true, self.Color, nil)
|
my_text := font.Render(self.FontObj,self.Text, true, self.Color, nil)
|
||||||
|
|
||||||
rect_ := &rect.Rect{self.PosX,self.PosY,self.Width,self.Height}
|
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||||
|
|
||||||
surface.Blit(self.CanvasHWND,my_text,rect_,nil)
|
surface.Blit(self.CanvasHWND,my_text,&rect_,nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,22 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
"github.com/cuu/gogame/display"
|
"github.com/cuu/gogame/display"
|
||||||
"github.com/cuu/gogame/surface"
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
"github.com/cuu/gogame/color"
|
"github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/font"
|
||||||
"github.com/cuu/gogame/time"
|
"github.com/cuu/gogame/time"
|
||||||
|
|
||||||
"github.com/cuu/gogame/event"
|
"github.com/cuu/gogame/event"
|
||||||
|
|
||||||
"../DBUS"
|
"../DBUS"
|
||||||
@ -23,7 +30,7 @@ var (
|
|||||||
type MessageBox struct {
|
type MessageBox struct {
|
||||||
Label
|
Label
|
||||||
Parent *MainScreen
|
Parent *MainScreen
|
||||||
|
HWND *sdl.Surface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessageBox() *MessageBox {
|
func NewMessageBox() *MessageBox {
|
||||||
@ -56,7 +63,7 @@ func (self *MessageBox) SetText( text string) {
|
|||||||
func (self *MessageBox) Draw() {
|
func (self *MessageBox) Draw() {
|
||||||
self.Width = 0
|
self.Width = 0
|
||||||
self.Height = 0
|
self.Height = 0
|
||||||
surface.Fill(self.CanvasHWND, color.Color{255,255,255,255} )
|
surface.Fill(self.CanvasHWND, &color.Color{255,255,255,255} )
|
||||||
|
|
||||||
words := strings.Split(self.Text," ")
|
words := strings.Split(self.Text," ")
|
||||||
space,_ := font.Size(self.FontObj," ")
|
space,_ := font.Size(self.FontObj," ")
|
||||||
@ -70,8 +77,8 @@ func (self *MessageBox) Draw() {
|
|||||||
|
|
||||||
for _,word := range words {
|
for _,word := range words {
|
||||||
word_surface := font.Render( self.FontObj, word, true, self.Color,nil)
|
word_surface := font.Render( self.FontObj, word, true, self.Color,nil)
|
||||||
word_width := word_surface.W
|
word_width := int(word_surface.W)
|
||||||
word_height := word_surface.H
|
word_height := int(word_surface.H)
|
||||||
row_total_width += word_width
|
row_total_width += word_width
|
||||||
if lines == 0 {
|
if lines == 0 {
|
||||||
lines += word_height
|
lines += word_height
|
||||||
@ -109,15 +116,20 @@ func (self *MessageBox) Draw() {
|
|||||||
|
|
||||||
rect_ := rect.Rect(x-padding,y-padding, self.Width+padding*2, self.Height+padding*2)
|
rect_ := rect.Rect(x-padding,y-padding, self.Width+padding*2, self.Height+padding*2)
|
||||||
|
|
||||||
draw.Rect(self.HWND , &color.Color{255,255,255,255},&rect_,0)
|
|
||||||
|
|
||||||
if self.HWND != nil {
|
if self.HWND != nil {
|
||||||
|
|
||||||
|
draw.Rect(self.HWND , &color.Color{255,255,255,255},&rect_,0)
|
||||||
|
|
||||||
rect__ := draw.MidRect(self.Parent.Width/2, self.Parent.Height/2,self.Width,self.Height,Width,Height)
|
rect__ := draw.MidRect(self.Parent.Width/2, self.Parent.Height/2,self.Width,self.Height,Width,Height)
|
||||||
dest_rect := rect.Rect(0,0,self.Width,self,Height)
|
|
||||||
surface.Blit(self.HWND, rect__, &dest_rect,nil)
|
dest_rect := rect.Rect(0,0,self.Width,self.Height)
|
||||||
|
|
||||||
|
surface.Blit(self.HWND, self.CanvasHWND, rect__, &dest_rect)
|
||||||
|
|
||||||
|
draw.Rect(self.HWND , &color.Color{0,0,0,255},&rect_,1)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw.Rect(self.HWND , &color.Color{0,0,0,255},&rect_,1)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +165,7 @@ func NewMainScreen() *MainScreen {
|
|||||||
|
|
||||||
m.MsgBoxFont = Fonts["veramono20"]
|
m.MsgBoxFont = Fonts["veramono20"]
|
||||||
m.IconFont = Fonts["varela15"]
|
m.IconFont = Fonts["varela15"]
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MainScreen) Init() {
|
func (self *MainScreen) Init() {
|
||||||
@ -160,12 +173,12 @@ func (self *MainScreen) Init() {
|
|||||||
|
|
||||||
self.MsgBox = NewMessageBox()
|
self.MsgBox = NewMessageBox()
|
||||||
self.MsgBox.Parent = self
|
self.MsgBox.Parent = self
|
||||||
self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83,83,83})
|
self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83,83,83,255})
|
||||||
|
|
||||||
self.SkinManager = NewSkinManager()
|
self.SkinManager = NewSkinManager()
|
||||||
self.SkinManager.Init()
|
self.SkinManager.Init()
|
||||||
|
|
||||||
self.DBusManager = NewDBus()
|
self.DBusManager = DBUS.NewDBus()
|
||||||
self.DBusManager.Init()
|
self.DBusManager.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +190,8 @@ func (self *MainScreen) FartherPages() { // right after ReadTheDirIntoPages
|
|||||||
self.Pages[i].SetCanvasHWND(self.CanvasHWND)
|
self.Pages[i].SetCanvasHWND(self.CanvasHWND)
|
||||||
self.Pages[i].UpdateIconNumbers() // IconNumbers always == len(Pages[i].Icons)
|
self.Pages[i].UpdateIconNumbers() // IconNumbers always == len(Pages[i].Icons)
|
||||||
self.Pages[i].SetScreen(self)
|
self.Pages[i].SetScreen(self)
|
||||||
|
self.Pages[i].Adjust()
|
||||||
|
|
||||||
if self.Pages[i].GetIconNumbers() > 1 {
|
if self.Pages[i].GetIconNumbers() > 1 {
|
||||||
self.Pages[i].SetPsIndex(1)
|
self.Pages[i].SetPsIndex(1)
|
||||||
self.Pages[i].SetIconIndex( 1 )
|
self.Pages[i].SetIconIndex( 1 )
|
||||||
@ -213,14 +227,16 @@ func (self *MainScreen) AppendPage( pg PageInterface ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *MainScreen) ClearCanvas() {
|
func (self *MainScreen) ClearCanvas() {
|
||||||
surface.Fill(self.CanvasHWND, color.Color{255,255,255,255} )
|
surface.Fill(self.CanvasHWND, &color.Color{255,255,255,255} )
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MainScreen) SwapAndShow() {
|
func (self *MainScreen) SwapAndShow() {
|
||||||
if self.HWND != nil {
|
if self.HWND != nil {
|
||||||
rect_ := rect.Rect( self.PosX,self.PosY,self.Width,self.Height)
|
rect_ := rect.Rect( self.PosX,self.PosY,self.Width,self.Height)
|
||||||
surface.Blit(self.HWND,self.CanvasHWND,*rect_, nil)
|
surface.Blit(self.HWND,self.CanvasHWND,&rect_, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display.Flip()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MainScreen) ExtraName(name string) string {
|
func (self *MainScreen) ExtraName(name string) string {
|
||||||
@ -308,9 +324,9 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
|
|||||||
untitled := NewUntitledIcon()
|
untitled := NewUntitledIcon()
|
||||||
untitled.Init()
|
untitled.Init()
|
||||||
if len(i2) > 1 {
|
if len(i2) > 1 {
|
||||||
untitled.SetWords(i2[0],i2[1])
|
untitled.SetWords(string(i2[0]),string(i2[1]))
|
||||||
}else if len(i2) == 1 {
|
}else if len(i2) == 1 {
|
||||||
untitled.SetWords(i2[0],i2[0])
|
untitled.SetWords(string(i2[0]),string(i2[0]))
|
||||||
}else {
|
}else {
|
||||||
untitled.SetWords("G","s")
|
untitled.SetWords("G","s")
|
||||||
}
|
}
|
||||||
@ -336,7 +352,7 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
|
|||||||
} else if IsAFile(_dir+"/"+f.Name()) && (pglevel > 0) {
|
} else if IsAFile(_dir+"/"+f.Name()) && (pglevel > 0) {
|
||||||
if strings.HasSuffix(strings.ToLower(f.Name()),IconExt) {
|
if strings.HasSuffix(strings.ToLower(f.Name()),IconExt) {
|
||||||
i2 := self.ExtraName(f.Name())
|
i2 := self.ExtraName(f.Name())
|
||||||
iconitem = NewIconItem()
|
iconitem := NewIconItem()
|
||||||
iconitem.CmdPath = _dir+"/"+f.Name()
|
iconitem.CmdPath = _dir+"/"+f.Name()
|
||||||
MakeExecutable( iconitem.CmdPath )
|
MakeExecutable( iconitem.CmdPath )
|
||||||
iconitem.MyType = ICON_TYPES["EXE"]
|
iconitem.MyType = ICON_TYPES["EXE"]
|
||||||
@ -346,9 +362,9 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
|
|||||||
untitled:= NewUntitledIcon()
|
untitled:= NewUntitledIcon()
|
||||||
untitled.Init()
|
untitled.Init()
|
||||||
if len(i2) > 1 {
|
if len(i2) > 1 {
|
||||||
untitled.SetWords(i2[0],i2[1])
|
untitled.SetWords(string(i2[0]),string(i2[1]))
|
||||||
}else if len(i2) == 1 {
|
}else if len(i2) == 1 {
|
||||||
untitled.SetWords(i2[0],i2[0])
|
untitled.SetWords(string(i2[0]),string(i2[0]))
|
||||||
}else {
|
}else {
|
||||||
untitled.SetWords("G","s")
|
untitled.SetWords("G","s")
|
||||||
}
|
}
|
||||||
@ -357,7 +373,7 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
|
|||||||
}
|
}
|
||||||
|
|
||||||
iconitem.AddLabel(strings.Split(i2,".")[0], self.IconFont)
|
iconitem.AddLabel(strings.Split(i2,".")[0], self.IconFont)
|
||||||
iconfont.LinkPage = nil
|
iconitem.LinkPage = nil
|
||||||
cur_page.AppendIcon(iconitem)
|
cur_page.AppendIcon(iconitem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,13 +422,17 @@ func (self *MainScreen) DrawRun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *MainScreen) Draw() {
|
func (self *MainScreen) Draw() {
|
||||||
self.CurrentPage.Draw()
|
if self.CurrentPage != nil {
|
||||||
|
self.CurrentPage.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
if self.TitleBar != nil {
|
if self.TitleBar != nil {
|
||||||
self.TitleBar.Draw( self.CurrentPage.GetName())
|
self.TitleBar.Draw( self.CurrentPage.GetName())
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.FootBar != nil {
|
if self.FootBar != nil {
|
||||||
self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
|
fmt.Println( len(self.CurrentPage.GetFootMsg()))
|
||||||
self.FootBar.Draw()
|
// self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
|
||||||
|
// self.FootBar.Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
"github.com/cuu/gogame/image"
|
"github.com/cuu/gogame/image"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
104
sysgo/UI/page.go
@ -1,14 +1,20 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
|
|
||||||
"github.com/cuu/gogame/font"
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
// "github.com/cuu/gogame/rect"
|
||||||
|
// "github.com/cuu/gogame/font"
|
||||||
"github.com/cuu/gogame/event"
|
"github.com/cuu/gogame/event"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/transform"
|
||||||
"../easings"
|
"../easings"
|
||||||
|
|
||||||
)
|
)
|
||||||
@ -101,11 +107,11 @@ func (self *PageSelector) Adjust(x,y,w,h,alpha int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *PageSelector) GetOnShow() bool {
|
func (self *PageSelector) GetOnShow() bool {
|
||||||
return self.Onshow
|
return self.OnShow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *PageSelector) SetOnShow( onshow bool ) {
|
func (self *PageSelector) SetOnShow( onshow bool ) {
|
||||||
self.Onshow = onshow
|
self.OnShow = onshow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *PageSelector) Draw() {
|
func (self *PageSelector) Draw() {
|
||||||
@ -118,13 +124,13 @@ func (self *PageSelector) Draw() {
|
|||||||
icon_x ,_ := icons[idx].Coord()
|
icon_x ,_ := icons[idx].Coord()
|
||||||
_,icon_y := icons[iconidx].Coord()
|
_,icon_y := icons[iconidx].Coord()
|
||||||
|
|
||||||
parent_x,parent_y := self.Parent.Coord()
|
parent_x,_ := self.Parent.Coord()
|
||||||
parent_w,parent_h := self.Parent.Size()
|
parent_w,parent_h := self.Parent.Size()
|
||||||
|
|
||||||
x := icon_x + parent_x
|
x := icon_x + parent_x
|
||||||
y := icon_y // only use current icon's PosY
|
y := icon_y // only use current icon's PosY
|
||||||
|
|
||||||
rect_ = draw.MidRect(x,y, self.Width, self.Height, parent_w,parent_h)
|
rect_ := draw.MidRect(x,y, self.Width, self.Height, parent_w,parent_h)
|
||||||
if rect_.W <=0 || rect_.H <= 0 {
|
if rect_.W <=0 || rect_.H <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -158,6 +164,12 @@ type PageInterface interface {
|
|||||||
SetPsIndex( idx int)
|
SetPsIndex( idx int)
|
||||||
GetPsIndex() int
|
GetPsIndex() int
|
||||||
|
|
||||||
|
SetIndex(idx int)
|
||||||
|
|
||||||
|
GetAlign() int
|
||||||
|
SetAlign(al int)
|
||||||
|
|
||||||
|
|
||||||
SetIconIndex(idx int)
|
SetIconIndex(idx int)
|
||||||
GetIconIndex() int
|
GetIconIndex() int
|
||||||
|
|
||||||
@ -167,6 +179,7 @@ type PageInterface interface {
|
|||||||
UpdateIconNumbers()
|
UpdateIconNumbers()
|
||||||
GetIconNumbers() int
|
GetIconNumbers() int
|
||||||
|
|
||||||
|
|
||||||
SetOnShow(on_show bool)
|
SetOnShow(on_show bool)
|
||||||
GetOnShow() bool
|
GetOnShow() bool
|
||||||
|
|
||||||
@ -210,7 +223,7 @@ type Page struct {
|
|||||||
|
|
||||||
Index int
|
Index int
|
||||||
|
|
||||||
Align string
|
Align int
|
||||||
|
|
||||||
CanvasHWND *sdl.Surface
|
CanvasHWND *sdl.Surface
|
||||||
HWND *sdl.Surface
|
HWND *sdl.Surface
|
||||||
@ -301,14 +314,14 @@ func (self *Page) AdjustSLeftAlign() { // ## adjust coordinator and append the P
|
|||||||
it.SetIndex(i)
|
it.SetIndex(i)
|
||||||
it.Adjust(start_x+i*self.PageIconMargin+i*IconWidth, start_y, IconWidth-6,IconHeight-6,0)
|
it.Adjust(start_x+i*self.PageIconMargin+i*IconWidth, start_y, IconWidth-6,IconHeight-6,0)
|
||||||
|
|
||||||
old_surf := it.GetImageSurf()
|
old_surf := it.GetImgSurf()
|
||||||
|
|
||||||
it_w,it_h := it.Size() //width height changed by Adjust above
|
it_w,it_h := it.Size() //width height changed by Adjust above
|
||||||
it.SetImageSurf( transform.SmoothScale(old_surf,it_w,it_h) )
|
it.SetImgSurf( transform.SmoothScale(old_surf,it_w,it_h) )
|
||||||
}
|
}
|
||||||
|
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(start_x,start_y,92,92,128)
|
ps.Init(start_x,start_y,92,92,128)
|
||||||
|
|
||||||
@ -341,9 +354,9 @@ func (self *Page) AdjustSAutoLeftAlign() { // ## adjust coordinator and append
|
|||||||
it.SetParent(self)
|
it.SetParent(self)
|
||||||
it.SetIndex(0)
|
it.SetIndex(0)
|
||||||
it.Adjust(start_x,start_y, IconWidth-6,IconHeight-6,0)
|
it.Adjust(start_x,start_y, IconWidth-6,IconHeight-6,0)
|
||||||
old_surf := it.GetImageSurf()
|
old_surf := it.GetImgSurf()
|
||||||
it_w,it_h := it.Size()
|
it_w,it_h := it.Size()
|
||||||
it.SetImageSurf( transform.SmoothScale(old_surf, it_w,it_h))
|
it.SetImgSurf( transform.SmoothScale(old_surf, it_w,it_h))
|
||||||
|
|
||||||
}else if self.IconNumbers == 2 {
|
}else if self.IconNumbers == 2 {
|
||||||
start_x = (self.Width - self.PageIconMargin - self.IconNumbers*IconWidth) / 2 + IconWidth/2
|
start_x = (self.Width - self.PageIconMargin - self.IconNumbers*IconWidth) / 2 + IconWidth/2
|
||||||
@ -354,9 +367,9 @@ func (self *Page) AdjustSAutoLeftAlign() { // ## adjust coordinator and append
|
|||||||
it.SetParent(self)
|
it.SetParent(self)
|
||||||
it.SetIndex(i)
|
it.SetIndex(i)
|
||||||
it.Adjust( start_x+ i*self.PageIconMargin+i*IconWidth, start_y, IconWidth-6, IconHeight-6,0)
|
it.Adjust( start_x+ i*self.PageIconMargin+i*IconWidth, start_y, IconWidth-6, IconHeight-6,0)
|
||||||
old_surf := it.GetImageSurf()
|
old_surf := it.GetImgSurf()
|
||||||
it_w,it_h := it.Size()
|
it_w,it_h := it.Size()
|
||||||
it.SetImageSurf( transform.SmoothScale( old_surf, it_w,it_h))
|
it.SetImgSurf( transform.SmoothScale( old_surf, it_w,it_h))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,14 +379,14 @@ func (self *Page) AdjustSAutoLeftAlign() { // ## adjust coordinator and append
|
|||||||
it.SetParent(self)
|
it.SetParent(self)
|
||||||
it.SetIndex(i)
|
it.SetIndex(i)
|
||||||
it.Adjust(start_x+i*self.PageIconMargin + i*IconWidth, start_y, IconWidth-6, IconHeight-6, 0)
|
it.Adjust(start_x+i*self.PageIconMargin + i*IconWidth, start_y, IconWidth-6, IconHeight-6, 0)
|
||||||
old_surf := it.GetImageSurf()
|
old_surf := it.GetImgSurf()
|
||||||
it_w,it_h := it.Size()
|
it_w,it_h := it.Size()
|
||||||
it.SetImageSurf( transform.SmoothScale( old_surf, it_w,it_h))
|
it.SetImgSurf( transform.SmoothScale( old_surf, it_w,it_h))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(start_x,start_y,92,92,128)
|
ps.Init(start_x,start_y,92,92,128)
|
||||||
|
|
||||||
@ -425,7 +438,7 @@ func (self *Page) InitLeftAlign() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(IconWidth/2,IconHeight/2,92,92,128)
|
ps.Init(IconWidth/2,IconHeight/2,92,92,128)
|
||||||
|
|
||||||
@ -448,14 +461,13 @@ func (self *Page) Adjust() { // default init way,
|
|||||||
start_y = self.Height/2
|
start_y = self.Height/2
|
||||||
|
|
||||||
for i:=0;i< self.IconNumbers; i++ {
|
for i:=0;i< self.IconNumbers; i++ {
|
||||||
it:=self.Icons[i]
|
self.Icons[i].SetParent(self)
|
||||||
it.SetParent(self)
|
self.Icons[i].SetIndex(i)
|
||||||
it.SetIndex(i)
|
self.Icons[i].Adjust(start_x + i*IconWidth, start_y, IconWidth, IconHeight,0)
|
||||||
it.Adjust(start_x + i*IconWidth, start_y, IconWidth, IconHeight,0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(start_x,start_y, 92,92,128)
|
ps.Init(start_x,start_y, 92,92,128)
|
||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
@ -472,7 +484,7 @@ func (self *Page) Adjust() { // default init way,
|
|||||||
it.Adjust(start_x + i*self.PageIconMargin+i*IconWidth, start_y, IconWidth, IconHeight,0)
|
it.Adjust(start_x + i*self.PageIconMargin+i*IconWidth, start_y, IconWidth, IconHeight,0)
|
||||||
}
|
}
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(start_x,start_y-self.SelectedIconTopOffset, 92,92,128)
|
ps.Init(start_x,start_y-self.SelectedIconTopOffset, 92,92,128)
|
||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
@ -533,7 +545,7 @@ func (self *Page) Init() {
|
|||||||
|
|
||||||
if self.IconNumbers > 0 {
|
if self.IconNumbers > 0 {
|
||||||
ps := NewPageSelector()
|
ps := NewPageSelector()
|
||||||
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
|
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
ps.Init(start_x,start_y, IconWidth+4, IconHeight+4, 128)
|
ps.Init(start_x,start_y, IconWidth+4, IconHeight+4, 128)
|
||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
@ -578,7 +590,7 @@ func (self *Page) IconStepMoveData(icon_eh ,cuts int) []int { // no Sine,No c
|
|||||||
dff := cuts - len(all_pieces)
|
dff := cuts - len(all_pieces)
|
||||||
var diffa []int
|
var diffa []int
|
||||||
for i:=0;i<dff;i++ {
|
for i:=0;i<dff;i++ {
|
||||||
diffa= diffa.append(0)
|
diffa= append(diffa,0)
|
||||||
}
|
}
|
||||||
|
|
||||||
all_pieces = append(all_pieces, diffa...)
|
all_pieces = append(all_pieces, diffa...)
|
||||||
@ -591,8 +603,8 @@ func (self *Page) EasingData(start,distance int) []int {
|
|||||||
current_time := 0.0
|
current_time := 0.0
|
||||||
start_posx := 0.0
|
start_posx := 0.0
|
||||||
current_posx := start_posx
|
current_posx := start_posx
|
||||||
final_posx := float(distance)
|
final_posx := float64(distance)
|
||||||
posx_init := start
|
// posx_init := start
|
||||||
dur := self.EasingDur
|
dur := self.EasingDur
|
||||||
last_posx := 0.0
|
last_posx := 0.0
|
||||||
|
|
||||||
@ -617,7 +629,7 @@ func (self *Page) EasingData(start,distance int) []int {
|
|||||||
c+=v
|
c+=v
|
||||||
}
|
}
|
||||||
if c < int(final_posx - start_posx) {
|
if c < int(final_posx - start_posx) {
|
||||||
all_last_posx = append(all_last_posx, int( final_posx - c ))
|
all_last_posx = append(all_last_posx, int( int(final_posx) - c ))
|
||||||
}
|
}
|
||||||
|
|
||||||
return all_last_posx
|
return all_last_posx
|
||||||
@ -628,7 +640,7 @@ func (self *Page) IconSmoothUp(icon_ew int) {
|
|||||||
data := self.EasingData(self.PosX,icon_ew)
|
data := self.EasingData(self.PosX,icon_ew)
|
||||||
data2 := self.IconStepMoveData(self.SelectedIconTopOffset, len(data))
|
data2 := self.IconStepMoveData(self.SelectedIconTopOffset, len(data))
|
||||||
|
|
||||||
for i,v := range data {
|
for i,_ := range data {
|
||||||
self.ClearCanvas()
|
self.ClearCanvas()
|
||||||
cur_icon_x,cur_icon_y := self.Icons[self.IconIndex].Coord()
|
cur_icon_x,cur_icon_y := self.Icons[self.IconIndex].Coord()
|
||||||
self.Icons[self.IconIndex].NewCoord(cur_icon_x, cur_icon_y - data2[i] )
|
self.Icons[self.IconIndex].NewCoord(cur_icon_x, cur_icon_y - data2[i] )
|
||||||
@ -790,8 +802,9 @@ func (self *Page) IconClick() {
|
|||||||
func (self *Page) ReturnToUpLevelPage() {
|
func (self *Page) ReturnToUpLevelPage() {
|
||||||
pop_page := self.Screen.MyPageStack.Pop()
|
pop_page := self.Screen.MyPageStack.Pop()
|
||||||
if pop_page != nil {
|
if pop_page != nil {
|
||||||
pop_page.Draw()
|
page_ := pop_page.(PageInterface)
|
||||||
self.Screen.SetCurPage(pop_page)
|
page_.Draw()
|
||||||
|
self.Screen.SetCurPage(page_)
|
||||||
}else {
|
}else {
|
||||||
if self.Screen.MyPageStack.Length() == 0 {
|
if self.Screen.MyPageStack.Length() == 0 {
|
||||||
if len(self.Screen.Pages) > 0 {
|
if len(self.Screen.Pages) > 0 {
|
||||||
@ -810,7 +823,7 @@ func (self *Page) ClearCanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Page) AppendIcon( it interface{} ) {
|
func (self *Page) AppendIcon( it interface{} ) {
|
||||||
self.Icons = append(self.Icons, it)
|
self.Icons = append(self.Icons, it.(IconItemInterface))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Page) GetIcons() []IconItemInterface {
|
func (self *Page) GetIcons() []IconItemInterface {
|
||||||
@ -957,3 +970,26 @@ func (self *Page) Size() (int,int) {
|
|||||||
func (self *Page) GetName() string {
|
func (self *Page) GetName() string {
|
||||||
return self.Name
|
return self.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Page) SetIndex(idx int) {
|
||||||
|
self.Index = idx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Page) SetAlign(al int) {
|
||||||
|
inthere := false
|
||||||
|
for _,v := range ALIGN {
|
||||||
|
if v == al {
|
||||||
|
inthere = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if inthere {
|
||||||
|
self.Align = al
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Page) GetAlign() int {
|
||||||
|
return self.Align
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"plugin"
|
"log"
|
||||||
|
goplugin "plugin"
|
||||||
)
|
)
|
||||||
var PluginPool = NewPluginPool()
|
var PluginPool = NewPluginPool()
|
||||||
|
|
||||||
type PluginInterface {
|
type PluginInterface interface {
|
||||||
Name() string
|
GetName() string
|
||||||
Init(screen *MainScreen)
|
Init(screen *MainScreen)
|
||||||
Run(screen *MainScreen)
|
Run(screen *MainScreen)
|
||||||
}
|
}
|
||||||
@ -15,7 +16,7 @@ type Plugin struct {
|
|||||||
Name string // only ID for plugin
|
Name string // only ID for plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Plugin) Name() string {
|
func (self *Plugin) GetName() string {
|
||||||
return self.Name
|
return self.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,20 +36,22 @@ func NewPluginPool() map[string]PluginInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PluginPoolRegister( pi PluginInterface ) bool {
|
func PluginPoolRegister( pi PluginInterface ) bool {
|
||||||
name := pi.Name()
|
name := pi.GetName()
|
||||||
|
|
||||||
if _,ok := PluginPool[name]; ok {
|
if _,ok := PluginPool[name]; ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginPool[name] = pi
|
PluginPool[name] = pi
|
||||||
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadPlugin( pname string) (*plugin.Plugin,error) {
|
func LoadPlugin( pname string) (*goplugin.Plugin,error) {
|
||||||
return plugin.Load(pname)
|
return goplugin.Open(pname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitPlugin(p *plugin.Plugin, main_screen *MainScreen) {
|
func InitPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
||||||
symAPI,err := p.Lookup("APIOBJ")
|
symAPI,err := p.Lookup("APIOBJ")
|
||||||
|
|
||||||
if err!= nil {
|
if err!= nil {
|
||||||
@ -66,7 +69,7 @@ func InitPlugin(p *plugin.Plugin, main_screen *MainScreen) {
|
|||||||
pi.Init(main_screen)
|
pi.Init(main_screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunPlugin(p *plugin.Plugin, main_screen *MainScreen) {
|
func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
||||||
symAPI,err := p.Lookup("APIOBJ")
|
symAPI,err := p.Lookup("APIOBJ")
|
||||||
|
|
||||||
if err!= nil {
|
if err!= nil {
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
package UI
|
||||||
@ -2,7 +2,11 @@ package UI
|
|||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-ini/ini"
|
"github.com/go-ini/ini"
|
||||||
|
|
||||||
@ -24,21 +28,26 @@ func NewSkinManager() *SkinManager {
|
|||||||
|
|
||||||
|
|
||||||
func (self *SkinManager) ConvertToRGB(hexstr string) *color.Color {
|
func (self *SkinManager) ConvertToRGB(hexstr string) *color.Color {
|
||||||
if len(hexstr) < 7 || hexstr[0] != '#' { // # 00 00 00
|
if len(hexstr) < 7 || string(hexstr[0]) != "#" { // # 00 00 00
|
||||||
log.Fatalf("ConvertToRGB hex string format error %s", hexstr)
|
log.Fatalf("ConvertToRGB hex string format error %s", hexstr)
|
||||||
|
//fmt.Printf("ConvertToRGB hex string format error %s", hexstr)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
h := strings.TrimLeft(hexstr,"#")
|
h := strings.TrimLeft(hexstr,"#")
|
||||||
|
|
||||||
r := strconv.ParseInt(hexstr[0:2], 16,0)
|
r,_ := strconv.ParseInt(h[0:2], 16,0)
|
||||||
g := strconv.ParseInt(hexstr[2:4], 16,0)
|
g,_ := strconv.ParseInt(h[2:4], 16,0)
|
||||||
b := strconv.ParseInt(hexstr[4:6], 16,0)
|
b,_ := strconv.ParseInt(h[4:6], 16,0)
|
||||||
|
|
||||||
col := &color.Color{ r,g,b,255 }
|
col := &color.Color{ uint32(r),uint32(g),uint32(b),255 }
|
||||||
return col
|
return col
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *SkinManager) ChangeSkin( skin_name string ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (self *SkinManager) Init() {
|
func (self *SkinManager) Init() {
|
||||||
self.Colors = make(map[string]*color.Color)
|
self.Colors = make(map[string]*color.Color)
|
||||||
|
|
||||||
@ -52,11 +61,14 @@ func (self *SkinManager) Init() {
|
|||||||
self.Colors["White"] = &color.Color{255,255,255,255}
|
self.Colors["White"] = &color.Color{255,255,255,255}
|
||||||
|
|
||||||
|
|
||||||
fname := "../skin/"+sysgo.SKIN+"/config.cfg"
|
fname := "skin/"+sysgo.SKIN+"/config.cfg"
|
||||||
|
|
||||||
cfg, err := ini.Load( fname )
|
load_opts := ini.LoadOptions{
|
||||||
|
IgnoreInlineComment:true,
|
||||||
|
}
|
||||||
|
cfg, err := ini.LoadSources(load_opts, fname )
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Fail to read file: %v", err)
|
fmt.Printf("Fail to read file: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,31 @@
|
|||||||
package UI
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"bufio"
|
"bufio"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
// "github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
"github.com/cuu/gogame/surface"
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
"github.com/cuu/gogame/font"
|
"github.com/cuu/gogame/font"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
|
||||||
"github.com/itchyny/volume-go"
|
"github.com/itchyny/volume-go"
|
||||||
|
|
||||||
"github.com/vjeantet/jodaTime"
|
"github.com/vjeantet/jodaTime"
|
||||||
|
|
||||||
|
"../DBUS"
|
||||||
|
|
||||||
"../../sysgo"
|
"../../sysgo"
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +62,7 @@ func (self *TitleBarIconItem) Draw() {
|
|||||||
|
|
||||||
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||||
|
|
||||||
surface.Blit(self.Parent.GetCanvasHWND(),
|
surface.Blit(self.Parent.CanvasHWND,
|
||||||
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||||
self.Width,self.Height, Width, Height),&portion)
|
self.Width,self.Height, Width, Height),&portion)
|
||||||
}
|
}
|
||||||
@ -70,15 +79,15 @@ type TitleBar struct {
|
|||||||
LOffset int
|
LOffset int
|
||||||
ROffset int
|
ROffset int
|
||||||
Icons map[string]IconItemInterface
|
Icons map[string]IconItemInterface
|
||||||
IconWidth
|
IconWidth int
|
||||||
IconHeight
|
IconHeight int
|
||||||
BorderWidth
|
BorderWidth int
|
||||||
CanvasHWND *sdl.Surface
|
CanvasHWND *sdl.Surface
|
||||||
HWND *sdl.Surface
|
HWND *sdl.Surface
|
||||||
Title string
|
Title string
|
||||||
InLowBackLight int
|
InLowBackLight int
|
||||||
SkinManager *SkinManager //set by MainScreen
|
SkinManager *SkinManager //set by MainScreen
|
||||||
DBusManager *DBusInterface
|
DBusManager DBUS.DBusInterface
|
||||||
|
|
||||||
icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
|
icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
|
||||||
|
|
||||||
@ -90,7 +99,6 @@ type TitleBar struct {
|
|||||||
func NewTitleBar() *TitleBar {
|
func NewTitleBar() *TitleBar {
|
||||||
t := &TitleBar{}
|
t := &TitleBar{}
|
||||||
|
|
||||||
|
|
||||||
t.BorderWidth = 1
|
t.BorderWidth = 1
|
||||||
|
|
||||||
t.BarHeight = TitleBar_BarHeight
|
t.BarHeight = TitleBar_BarHeight
|
||||||
@ -110,9 +118,11 @@ func NewTitleBar() *TitleBar {
|
|||||||
|
|
||||||
t.TitleFont = Fonts["varela12"]
|
t.TitleFont = Fonts["varela12"]
|
||||||
t.TimeFont = Fonts["varela16"]
|
t.TimeFont = Fonts["varela16"]
|
||||||
|
return t
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TitleBar) RoundRobinCheck {
|
func (t *TitleBar) RoundRobinCheck() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,14 +131,14 @@ func (t *TitleBar) UpdateWifiStrength() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TitleBar) GetWifiStrength(stren int) int {
|
func (t *TitleBar) GetWifiStrength(stren int) int {
|
||||||
segs := [][]int{ []int{-2,-1}, []int{0,25}, []int{25,50}, []int{50,75},int{75,100}}
|
segs := [][]int{ []int{-2,-1}, []int{0,25}, []int{25,50}, []int{50,75},[]int{75,100}}
|
||||||
stren_number := stren
|
stren_number := stren
|
||||||
ge := 0
|
ge := 0
|
||||||
if stren_number == 0 {
|
if stren_number == 0 {
|
||||||
return ge
|
return ge
|
||||||
}
|
}
|
||||||
|
|
||||||
for i,v in range segs {
|
for i,v := range segs {
|
||||||
if stren_number >= v[0] && stren_number <= v[1] {
|
if stren_number >= v[0] && stren_number <= v[1] {
|
||||||
ge = i
|
ge = i
|
||||||
break
|
break
|
||||||
@ -150,7 +160,7 @@ func (self *TitleBar) SyncSoundVolume() {
|
|||||||
snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} }
|
snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} }
|
||||||
ge := 0
|
ge := 0
|
||||||
|
|
||||||
for i,v in range snd_segs {
|
for i,v := range snd_segs {
|
||||||
if vol >= v[0] && vol <= v[1] {
|
if vol >= v[0] && vol <= v[1] {
|
||||||
ge = i
|
ge = i
|
||||||
break
|
break
|
||||||
@ -178,7 +188,7 @@ func (self *TitleBar) CheckBatteryStat() {
|
|||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
bat_uevent := make([string]string)
|
bat_uevent := make(map[string]string)
|
||||||
|
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
scanner.Split(bufio.ScanLines)
|
scanner.Split(bufio.ScanLines)
|
||||||
@ -195,14 +205,14 @@ func (self *TitleBar) CheckBatteryStat() {
|
|||||||
cur_cap := 0
|
cur_cap := 0
|
||||||
|
|
||||||
if val, ok := bat_uevent["POWER_SUPPLY_CAPACITY"]; ok {
|
if val, ok := bat_uevent["POWER_SUPPLY_CAPACITY"]; ok {
|
||||||
cur_cap = strings.Atoi(val)
|
cur_cap,_ = strconv.Atoi(val)
|
||||||
}else {
|
}else {
|
||||||
cur_cap = 0
|
cur_cap = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cap_ge := 0
|
cap_ge := 0
|
||||||
|
|
||||||
for i,v in range bat_segs {
|
for i,v := range bat_segs {
|
||||||
if cur_cap >= v[0] && cur_cap <= v[1] {
|
if cur_cap >= v[0] && cur_cap <= v[1] {
|
||||||
cap_ge = i
|
cap_ge = i
|
||||||
break
|
break
|
||||||
@ -286,7 +296,7 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
|
|||||||
|
|
||||||
round_corners.MyType = ICON_TYPES["STAT"]
|
round_corners.MyType = ICON_TYPES["STAT"]
|
||||||
round_corners.Parent = self
|
round_corners.Parent = self
|
||||||
round_corners.ImgSurf = MyIconPool.GetImageSurf["roundcorners"]
|
round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
|
||||||
round_corners.Adjust(0,0,10,10,0)
|
round_corners.Adjust(0,0,10,10,0)
|
||||||
|
|
||||||
self.Icons["round_corners"] = round_corners
|
self.Icons["round_corners"] = round_corners
|
||||||
@ -320,12 +330,12 @@ func (self *TitleBar) Draw(title string) {
|
|||||||
time_text_w, time_text_h := font.Size(self.TimeFont, cur_time)
|
time_text_w, time_text_h := font.Size(self.TimeFont, cur_time)
|
||||||
title_text_w, title_text_h := font.Size(self.TitleFont, self.Title)
|
title_text_w, title_text_h := font.Size(self.TitleFont, self.Title)
|
||||||
|
|
||||||
title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"))
|
title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"),nil)
|
||||||
|
|
||||||
surface.Blit(self.CanvasHWND,title_text_surf, draw.MidRect(title_text_w/2+self.LOffset,title_text_h/2+(self.BarHeight-title_text_h)/2,title_text_w,title_text_h,Width,Height),nil)
|
surface.Blit(self.CanvasHWND,title_text_surf, draw.MidRect(title_text_w/2+self.LOffset,title_text_h/2+(self.BarHeight-title_text_h)/2,title_text_w,title_text_h,Width,Height),nil)
|
||||||
|
|
||||||
|
|
||||||
time_text_surf := font.Render(self.TimeFont, cur_time,true,self.SkinManager.GiveColor("Text"))
|
time_text_surf := font.Render(self.TimeFont, cur_time,true,self.SkinManager.GiveColor("Text"),nil)
|
||||||
surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
|
surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
|
||||||
|
|
||||||
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
|
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
|
||||||
|
|||||||
@ -6,8 +6,11 @@ import (
|
|||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
"github.com/cuu/gogame/draw"
|
"github.com/cuu/gogame/draw"
|
||||||
"github.com/cuu/gogame/color"
|
"github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/image"
|
||||||
|
"github.com/cuu/gogame/font"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +20,7 @@ type UntitledIcon struct {
|
|||||||
PosY int
|
PosY int
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
Words [2]string
|
Words []string
|
||||||
FontObj *ttf.Font
|
FontObj *ttf.Font
|
||||||
BG *sdl.Surface
|
BG *sdl.Surface
|
||||||
Color *color.Color
|
Color *color.Color
|
||||||
@ -29,18 +32,19 @@ func NewUntitledIcon() *UntitledIcon {
|
|||||||
u := &UntitledIcon{}
|
u := &UntitledIcon{}
|
||||||
u.Width = 80
|
u.Width = 80
|
||||||
u.Height = 80
|
u.Height = 80
|
||||||
u.Words = [2]string{"G","s"}
|
u.Words = []string{"G","s"}
|
||||||
|
|
||||||
u.FontObj = Fonts["varela40"]
|
u.FontObj = Fonts["varela40"]
|
||||||
|
|
||||||
u.Color = &color.Color{83,83,83,255}
|
u.Color = &color.Color{83,83,83,255}
|
||||||
|
|
||||||
u.BlankPng = SkinMap("gameshell/blank.png")
|
u.BlankPng = SkinMap("gameshell/blank.png")
|
||||||
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UntitledIcon) Init() {
|
func (self *UntitledIcon) Init() {
|
||||||
self.BG = image.Load(self.BlankPng)
|
self.BG = image.Load(self.BlankPng)
|
||||||
)
|
}
|
||||||
|
|
||||||
func (self *UntitledIcon) SetWords( TwoWords ...string) {
|
func (self *UntitledIcon) SetWords( TwoWords ...string) {
|
||||||
if len(TwoWords) == 1 {
|
if len(TwoWords) == 1 {
|
||||||
@ -59,7 +63,7 @@ func (self *UntitledIcon) Draw() {
|
|||||||
w_ := self.Text.W
|
w_ := self.Text.W
|
||||||
h_ := self.Text.H
|
h_ := self.Text.H
|
||||||
|
|
||||||
surface.Blit(self.BG,self.Text,draw.MidRect(self.Width/2, self.Height/2,w_,h_, self.Width, self.Height),nil)
|
surface.Blit(self.BG,self.Text,draw.MidRect(self.Width/2, self.Height/2, int(w_),int(h_), self.Width, self.Height),nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,15 +14,16 @@ import (
|
|||||||
func SkinMap(orig_file_or_dir string) string {
|
func SkinMap(orig_file_or_dir string) string {
|
||||||
DefaultSkin := "default"
|
DefaultSkin := "default"
|
||||||
ret := ""
|
ret := ""
|
||||||
|
skin_dir_prefix:= "skin/"
|
||||||
if strings.HasPrefix(orig_file_or_dir, "..") {
|
if strings.HasPrefix(orig_file_or_dir, "..") {
|
||||||
ret = strings.Replace(orig_file_or_dir,"..","../skin/"+sysgo.SKIN,-1)
|
ret = strings.Replace(orig_file_or_dir,"..",skin_dir_prefix + sysgo.SKIN,-1)
|
||||||
if FileExists(ret) == false {
|
if FileExists(ret) == false {
|
||||||
ret = strings.Replace(orig_file_or_dir,"..", "../skin/"+DefaultSkin)
|
ret = strings.Replace(orig_file_or_dir,"..", skin_dir_prefix + DefaultSkin,-1)
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
ret = "../skin/"+sysgo.SKIN+"/sysgo/"+orig_file_or_dir
|
ret = skin_dir_prefix+sysgo.SKIN+"/sysgo/"+orig_file_or_dir
|
||||||
if FileExists(ret) == false {
|
if FileExists(ret) == false {
|
||||||
ret = "../skin/"+DefaultSkin+"/sysgo/"+orig_file_or_dir
|
ret = skin_dir_prefix+DefaultSkin+"/sysgo/"+orig_file_or_dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
## easings [](https://godoc.org/github.com/gen2brain/raylib-go/easings)
|
|
||||||
|
|
||||||
Useful easing functions for values animation.
|
|
||||||
|
|
||||||
A port of Robert Penner's [easing equations](http://robertpenner.com/easing/).
|
|
||||||
|
|
||||||

|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"../../../UI"
|
"../../UI"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HelloWorldPage struct {
|
type HelloWorldPage struct {
|
||||||