still footbar can not draw

This commit is contained in:
cuu 2018-06-18 16:17:31 +08:00
parent 20ea392215
commit c9de67c78f
55 changed files with 3388 additions and 157 deletions

View 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

View 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"

File diff suppressed because it is too large Load Diff

View 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

View 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
View 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
View File

@ -0,0 +1 @@
retroarch

1
Menu/GameShell/freeDM.sh Executable file
View File

@ -0,0 +1 @@
chocolate-doom -iwad /home/cpi/games/FreeDM/freedoom1.wad

BIN
main Executable file

Binary file not shown.

92
main.go Normal file
View 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)
}

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 306 B

View File

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 294 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

View File

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 335 B

After

Width:  |  Height:  |  Size: 335 B

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 545 B

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 427 B

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

View File

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 601 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B

View File

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 627 B

View File

@ -1,6 +1,8 @@
package DBUS
import (
"fmt"
"strconv"
"github.com/godbus/dbus"
)

View File

@ -0,0 +1,2 @@
package UI

View File

@ -15,7 +15,7 @@ var Fonts map[string]*ttf.Font
func init() {
font.Init()
skinpath := "../skin/"+sysgo.SKIN+"/truetype"
skinpath := "skin/"+sysgo.SKIN+"/truetype"
Fonts = make(map[string]*ttf.Font)

View File

@ -1,11 +1,18 @@
package UI
import (
"fmt"
// "io/ioutil"
"log"
"github.com/veandco/go-sdl2/sdl"
"github.com/veandco/go-sdl2/ttf"
"github.com/cuu/gogame/rect"
"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
State string
SkinManager *SkinManager
icon_base_path string
}
@ -93,13 +101,7 @@ func (self *FootBar) ReadFootBarIcons( icondir string) {
}
keynames := [5]string{"nav","x","y","a","b"}
share_surf := image.Load(icon_base_path+"footbar.png")
files,err := ioutil.ReadDir(icondir)
if err != nil {
log.Fatal(err)
return
}
share_surf := image.Load(self.icon_base_path+"footbar.png")
for i,v := range keynames { // share_surf contains same number of image pieces of keynames
it := NewFootBarIconItem()
@ -119,8 +121,6 @@ func (self *FootBar) Init(main_screen *MainScreen) {
self.CanvasHWND = surface.Surface(self.Width,self.Height)
self.HWND = main_screen.HWND
self.SkinManager = main_screen.SkinManager
self.DBusManager = main_screen.DBusManager
round_corners := NewFootBarIconItem()
round_corners.IconWidth = 10
@ -128,7 +128,7 @@ func (self *FootBar) Init(main_screen *MainScreen) {
round_corners.MyType = ICON_TYPES["STAT"]
round_corners.Parent = self
round_corners.ImgSurf = MyIconPool.GetImageSurf["roundcorners"]
round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
round_corners.Adjust(0,0,10,10,0)
self.Icons["round_corners"] = round_corners
@ -136,14 +136,15 @@ func (self *FootBar) Init(main_screen *MainScreen) {
}
func (self *FootBar) ResetNavText() {
self.Icons["nav"].Label.SetText("Nav.")
self.Icons["nav"].SetLabelText("Nav.")
self.State = "normal"
self.Draw()
}
func (self *FootBar) UpdateNavText(texts string) {
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
@ -151,21 +152,21 @@ func (self *FootBar) UpdateNavText(texts string) {
for i,_ := range texts {
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_
if my_text.W >= left_width {
if int(my_text.W) >= left_width {
break
}
}
fmt.Printf("finalpiece %s\n", final_piece)
self.Icons["nav"].Label.SetText(final_piece)
self.Icons["nav"].SetLabelText(final_piece)
self.Draw()
}
func (self *FootBar) SetLabelTexts( texts []string) {
func (self *FootBar) SetLabelTexts( texts [5]string) {
keynames := [5]string{"nav","x","y","a","b"}
if len(texts) < 5 {
log.Fatal("SetLabelTexts texts length error")
@ -173,7 +174,7 @@ func (self *FootBar) SetLabelTexts( texts []string) {
}
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
for i,x := range []string{"b","a","y","x"} {
if self.Icons[x].Label.GetText() != "" {
if self.Icons[x].GetLabelText() != "" {
if i== 0 {
_w += self.Icons[x].TotalWidth()
}else {
@ -215,11 +216,12 @@ func (self *FootBar) Draw() {
self.Icons[x].Draw()
}
}
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)
surface.Blit(self.HWND,self.CanvasHWND, &rect_,nil)
}
}
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)
surface.Blit(self.HWND,self.CanvasHWND, &rect_,nil)
}
}

View File

@ -5,6 +5,10 @@ import (
"github.com/veandco/go-sdl2/sdl"
"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/utils"
)
@ -27,20 +31,29 @@ type IconItemInterface interface {
SetParent( p interface{} )
SetLabelColor(col *color.Color)
SetLabelText(text string)
GetLabelText() string
Coord() (int,int)
NewCoord(x,y int)
TotalWidth() int
Size() (int,int)
AddLabel(text string, fontobj *ttf.Font)
GetLinkPage() PageInterface
AdjustLinkPage()
GetImageSurf() *sdl.Surface
SetImageSurf(newsurf *sdl.Surface)
CreateImageSurf()
GetImgSurf() *sdl.Surface
SetImgSurf(newsurf *sdl.Surface)
CreateImgSurf()
ChangeImgSurfColor(col *color.Color)
Clear()
GetCmdInvoke() PluginInterface
Draw()
}
@ -86,7 +99,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
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.PosY = y
self.Width = w
@ -97,7 +110,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
self.Label.SetCanvasHWND(self.Parent.GetCanvasHWND())
}
self.CreateImageSurf()
self.CreateImgSurf()
self.AdjustLinkPage()
}
@ -136,13 +149,21 @@ func (self *IconItem) SetIndex(i int) {
}
func (self *IconItem) SetParent(p interface{} ) {
self.Parent = p
self.Parent = p.(PageInterface)
}
func (self *IconItem) SetLabelColor(col *color.Color) {
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) {
return self.PosX,self.PosY
}
@ -153,7 +174,7 @@ func (self *IconItem) NewCoord(x,y int) {
}
func (self *IconItem) TotalWidth() int {
return 0
}
func (self *IconItem) Size() (int,int) {
@ -165,7 +186,7 @@ func (self *IconItem) AddLabel(text string, fontobj *ttf.Font) {
l:= NewLabel()
self.Label = l
}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 {
self.LinkPage.SetIndex(0)
self.LinkPage.SetAlign(ALIGN["SLeft"])
self.LinkPage.SetIconNumbers( len(self.LinkPage.GetIcons()) )
self.LinkPage.UpdateIconNumbers()
self.LinkPage.SetScreen(self.Parent.GetScreen())
self.LinkPage.SetCanvasHWND( (self.Parent.GetScreen()).CanvasHWND )
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
}
func (self *IconItem) SetImageSurf(newsurf *sdl.Surface) {
func (self *IconItem) SetImgSurf(newsurf *sdl.Surface) {
self.ImgSurf = newsurf
}
func (self *IconItem) CreateImageSurf() {
func (self *IconItem) CreateImgSurf() {
if self.ImgSurf == nil && 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)
}
}
@ -216,12 +237,20 @@ func (self *IconItem) ChangeImgSurfColor(col *color.Color) {
utils.ColorSurface(self.ImgSurf,col)
}
func (self *IconItem) Clear() {
}
func (self *IconItem) GetCmdInvoke() PluginInterface {
return self.CmdInvoke
}
func (self *IconItem) Draw() {
parent_x,parent_y := self.Parent.Coord()
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()
if self.Align == ALIGN["VCenter"] {

View File

@ -46,7 +46,7 @@ func (self *IconPool) Init() {
}
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]
} else {
return nil

View File

@ -1,7 +1,7 @@
package UI
import (
"../sysgo"
"../../sysgo"
)

View File

@ -1,15 +1,18 @@
package UI
import (
"github.com/veandco/go-sdl2/sdl"
"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/font"
)
type LabelInterface interface {
Init( text string, font_obj *ttf.Font,col *color.Color )
SetCanvasHWND( canvas *sdl.Surface)
Coord() (int,int)
Size() (int,int)
NewCoord(x,y int)
@ -31,7 +34,7 @@ type Label struct {
// TextSurf *sdl.Surface
}
func NewLabel() *Label() {
func NewLabel() *Label {
l := &Label{}
l.Color = &color.Color{83,83,83,255}
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) {
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
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)
}

View File

@ -1,15 +1,22 @@
package UI
import (
"fmt"
"io/ioutil"
"strings"
"log"
"github.com/veandco/go-sdl2/sdl"
"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/draw"
"github.com/cuu/gogame/color"
"github.com/cuu/gogame/rect"
"github.com/cuu/gogame/font"
"github.com/cuu/gogame/time"
"github.com/cuu/gogame/event"
"../DBUS"
@ -23,7 +30,7 @@ var (
type MessageBox struct {
Label
Parent *MainScreen
HWND *sdl.Surface
}
func NewMessageBox() *MessageBox {
@ -56,7 +63,7 @@ func (self *MessageBox) SetText( text string) {
func (self *MessageBox) Draw() {
self.Width = 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," ")
space,_ := font.Size(self.FontObj," ")
@ -70,8 +77,8 @@ func (self *MessageBox) Draw() {
for _,word := range words {
word_surface := font.Render( self.FontObj, word, true, self.Color,nil)
word_width := word_surface.W
word_height := word_surface.H
word_width := int(word_surface.W)
word_height := int(word_surface.H)
row_total_width += word_width
if lines == 0 {
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)
draw.Rect(self.HWND , &color.Color{255,255,255,255},&rect_,0)
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)
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.IconFont = Fonts["varela15"]
return m
}
func (self *MainScreen) Init() {
@ -160,12 +173,12 @@ func (self *MainScreen) Init() {
self.MsgBox = NewMessageBox()
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.Init()
self.DBusManager = NewDBus()
self.DBusManager = DBUS.NewDBus()
self.DBusManager.Init()
}
@ -177,7 +190,8 @@ func (self *MainScreen) FartherPages() { // right after ReadTheDirIntoPages
self.Pages[i].SetCanvasHWND(self.CanvasHWND)
self.Pages[i].UpdateIconNumbers() // IconNumbers always == len(Pages[i].Icons)
self.Pages[i].SetScreen(self)
self.Pages[i].Adjust()
if self.Pages[i].GetIconNumbers() > 1 {
self.Pages[i].SetPsIndex(1)
self.Pages[i].SetIconIndex( 1 )
@ -213,14 +227,16 @@ func (self *MainScreen) AppendPage( pg PageInterface ) {
}
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() {
if self.HWND != nil {
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 {
@ -308,9 +324,9 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
untitled := NewUntitledIcon()
untitled.Init()
if len(i2) > 1 {
untitled.SetWords(i2[0],i2[1])
untitled.SetWords(string(i2[0]),string(i2[1]))
}else if len(i2) == 1 {
untitled.SetWords(i2[0],i2[0])
untitled.SetWords(string(i2[0]),string(i2[0]))
}else {
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) {
if strings.HasSuffix(strings.ToLower(f.Name()),IconExt) {
i2 := self.ExtraName(f.Name())
iconitem = NewIconItem()
iconitem := NewIconItem()
iconitem.CmdPath = _dir+"/"+f.Name()
MakeExecutable( iconitem.CmdPath )
iconitem.MyType = ICON_TYPES["EXE"]
@ -346,9 +362,9 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
untitled:= NewUntitledIcon()
untitled.Init()
if len(i2) > 1 {
untitled.SetWords(i2[0],i2[1])
untitled.SetWords(string(i2[0]),string(i2[1]))
}else if len(i2) == 1 {
untitled.SetWords(i2[0],i2[0])
untitled.SetWords(string(i2[0]),string(i2[0]))
}else {
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)
iconfont.LinkPage = nil
iconitem.LinkPage = nil
cur_page.AppendIcon(iconitem)
}
}
@ -406,13 +422,17 @@ func (self *MainScreen) DrawRun() {
}
func (self *MainScreen) Draw() {
self.CurrentPage.Draw()
if self.CurrentPage != nil {
self.CurrentPage.Draw()
}
if self.TitleBar != nil {
self.TitleBar.Draw( self.CurrentPage.GetName())
}
if self.FootBar != nil {
self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
self.FootBar.Draw()
fmt.Println( len(self.CurrentPage.GetFootMsg()))
// self.FootBar.SetLabelTexts( self.CurrentPage.GetFootMsg())
// self.FootBar.Draw()
}
}

View File

@ -1,7 +1,10 @@
package UI
import (
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/image"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/rect"
)

View File

@ -1,14 +1,20 @@
package UI
import (
"fmt"
"math"
"sync"
"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/transform"
"../easings"
)
@ -101,11 +107,11 @@ func (self *PageSelector) Adjust(x,y,w,h,alpha int) {
}
func (self *PageSelector) GetOnShow() bool {
return self.Onshow
return self.OnShow
}
func (self *PageSelector) SetOnShow( onshow bool ) {
self.Onshow = onshow
self.OnShow = onshow
}
func (self *PageSelector) Draw() {
@ -118,13 +124,13 @@ func (self *PageSelector) Draw() {
icon_x ,_ := icons[idx].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()
x := icon_x + parent_x
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 {
return
}
@ -158,6 +164,12 @@ type PageInterface interface {
SetPsIndex( idx int)
GetPsIndex() int
SetIndex(idx int)
GetAlign() int
SetAlign(al int)
SetIconIndex(idx int)
GetIconIndex() int
@ -167,6 +179,7 @@ type PageInterface interface {
UpdateIconNumbers()
GetIconNumbers() int
SetOnShow(on_show bool)
GetOnShow() bool
@ -210,7 +223,7 @@ type Page struct {
Index int
Align string
Align int
CanvasHWND *sdl.Surface
HWND *sdl.Surface
@ -301,14 +314,14 @@ func (self *Page) AdjustSLeftAlign() { // ## adjust coordinator and append the P
it.SetIndex(i)
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.SetImageSurf( transform.SmoothScale(old_surf,it_w,it_h) )
it.SetImgSurf( transform.SmoothScale(old_surf,it_w,it_h) )
}
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
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.SetIndex(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.SetImageSurf( transform.SmoothScale(old_surf, it_w,it_h))
it.SetImgSurf( transform.SmoothScale(old_surf, it_w,it_h))
}else if self.IconNumbers == 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.SetIndex(i)
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.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.SetIndex(i)
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.SetImageSurf( transform.SmoothScale( old_surf, it_w,it_h))
it.SetImgSurf( transform.SmoothScale( old_surf, it_w,it_h))
}
}
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
ps.Init(start_x,start_y,92,92,128)
@ -425,7 +438,7 @@ func (self *Page) InitLeftAlign() {
}
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
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
for i:=0;i< self.IconNumbers; i++ {
it:=self.Icons[i]
it.SetParent(self)
it.SetIndex(i)
it.Adjust(start_x + i*IconWidth, start_y, IconWidth, IconHeight,0)
self.Icons[i].SetParent(self)
self.Icons[i].SetIndex(i)
self.Icons[i].Adjust(start_x + i*IconWidth, start_y, IconWidth, IconHeight,0)
}
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
ps.Init(start_x,start_y, 92,92,128)
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)
}
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
ps.Init(start_x,start_y-self.SelectedIconTopOffset, 92,92,128)
self.Ps = ps
@ -533,7 +545,7 @@ func (self *Page) Init() {
if self.IconNumbers > 0 {
ps := NewPageSelector()
ps.IconSurf = MyIconPool.GetImageSurf("blueselector")
ps.IconSurf = MyIconPool.GetImgSurf("blueselector")
ps.Parent = self
ps.Init(start_x,start_y, IconWidth+4, IconHeight+4, 128)
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)
var diffa []int
for i:=0;i<dff;i++ {
diffa= diffa.append(0)
diffa= append(diffa,0)
}
all_pieces = append(all_pieces, diffa...)
@ -591,8 +603,8 @@ func (self *Page) EasingData(start,distance int) []int {
current_time := 0.0
start_posx := 0.0
current_posx := start_posx
final_posx := float(distance)
posx_init := start
final_posx := float64(distance)
// posx_init := start
dur := self.EasingDur
last_posx := 0.0
@ -617,7 +629,7 @@ func (self *Page) EasingData(start,distance int) []int {
c+=v
}
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
@ -628,7 +640,7 @@ func (self *Page) IconSmoothUp(icon_ew int) {
data := self.EasingData(self.PosX,icon_ew)
data2 := self.IconStepMoveData(self.SelectedIconTopOffset, len(data))
for i,v := range data {
for i,_ := range data {
self.ClearCanvas()
cur_icon_x,cur_icon_y := self.Icons[self.IconIndex].Coord()
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() {
pop_page := self.Screen.MyPageStack.Pop()
if pop_page != nil {
pop_page.Draw()
self.Screen.SetCurPage(pop_page)
page_ := pop_page.(PageInterface)
page_.Draw()
self.Screen.SetCurPage(page_)
}else {
if self.Screen.MyPageStack.Length() == 0 {
if len(self.Screen.Pages) > 0 {
@ -810,7 +823,7 @@ func (self *Page) ClearCanvas() {
}
func (self *Page) AppendIcon( it interface{} ) {
self.Icons = append(self.Icons, it)
self.Icons = append(self.Icons, it.(IconItemInterface))
}
func (self *Page) GetIcons() []IconItemInterface {
@ -957,3 +970,26 @@ func (self *Page) Size() (int,int) {
func (self *Page) GetName() string {
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
}

View File

@ -1,12 +1,13 @@
package UI
import (
"plugin"
"log"
goplugin "plugin"
)
var PluginPool = NewPluginPool()
type PluginInterface {
Name() string
type PluginInterface interface {
GetName() string
Init(screen *MainScreen)
Run(screen *MainScreen)
}
@ -15,7 +16,7 @@ type Plugin struct {
Name string // only ID for plugin
}
func (self *Plugin) Name() string {
func (self *Plugin) GetName() string {
return self.Name
}
@ -35,20 +36,22 @@ func NewPluginPool() map[string]PluginInterface {
}
func PluginPoolRegister( pi PluginInterface ) bool {
name := pi.Name()
name := pi.GetName()
if _,ok := PluginPool[name]; ok {
return false
}
PluginPool[name] = pi
return true
}
func LoadPlugin( pname string) (*plugin.Plugin,error) {
return plugin.Load(pname)
func LoadPlugin( pname string) (*goplugin.Plugin,error) {
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")
if err!= nil {
@ -66,7 +69,7 @@ func InitPlugin(p *plugin.Plugin, main_screen *MainScreen) {
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")
if err!= nil {

View File

@ -0,0 +1 @@
package UI

View File

@ -2,7 +2,11 @@ package UI
import (
"fmt"
"log"
"strings"
"strconv"
"github.com/go-ini/ini"
@ -24,21 +28,26 @@ func NewSkinManager() *SkinManager {
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)
//fmt.Printf("ConvertToRGB hex string format error %s", hexstr)
return nil
}
h := strings.TrimLeft(hexstr,"#")
r := strconv.ParseInt(hexstr[0:2], 16,0)
g := strconv.ParseInt(hexstr[2:4], 16,0)
b := strconv.ParseInt(hexstr[4:6], 16,0)
r,_ := strconv.ParseInt(h[0:2], 16,0)
g,_ := strconv.ParseInt(h[2:4], 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
}
func (self *SkinManager) ChangeSkin( skin_name string ) {
}
func (self *SkinManager) Init() {
self.Colors = make(map[string]*color.Color)
@ -52,11 +61,14 @@ func (self *SkinManager) Init() {
self.Colors["White"] = &color.Color{255,255,255,255}
fname := "../skin/"+sysgo.SKIN+"/config.cfg"
cfg, err := ini.Load( fname )
fname := "skin/"+sysgo.SKIN+"/config.cfg"
load_opts := ini.LoadOptions{
IgnoreInlineComment:true,
}
cfg, err := ini.LoadSources(load_opts, fname )
if err != nil {
fmt.Printf("Fail to read file: %v", err)
fmt.Printf("Fail to read file: %v\n", err)
return
}

View File

@ -1,22 +1,31 @@
package UI
import (
"fmt"
"os"
"log"
"strconv"
"bufio"
"strings"
"time"
"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/font"
"github.com/cuu/gogame/draw"
"github.com/itchyny/volume-go"
"github.com/vjeantet/jodaTime"
"../DBUS"
"../../sysgo"
)
@ -53,7 +62,7 @@ func (self *TitleBarIconItem) Draw() {
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.Width,self.Height, Width, Height),&portion)
}
@ -70,15 +79,15 @@ type TitleBar struct {
LOffset int
ROffset int
Icons map[string]IconItemInterface
IconWidth
IconHeight
BorderWidth
IconWidth int
IconHeight int
BorderWidth int
CanvasHWND *sdl.Surface
HWND *sdl.Surface
Title string
InLowBackLight int
SkinManager *SkinManager //set by MainScreen
DBusManager *DBusInterface
DBusManager DBUS.DBusInterface
icon_base_path string /// SkinMap("gameshell/titlebar_icons/")
@ -90,7 +99,6 @@ type TitleBar struct {
func NewTitleBar() *TitleBar {
t := &TitleBar{}
t.BorderWidth = 1
t.BarHeight = TitleBar_BarHeight
@ -110,9 +118,11 @@ func NewTitleBar() *TitleBar {
t.TitleFont = Fonts["varela12"]
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 {
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
ge := 0
if stren_number == 0 {
return ge
}
for i,v in range segs {
for i,v := range segs {
if stren_number >= v[0] && stren_number <= v[1] {
ge = i
break
@ -150,7 +160,7 @@ func (self *TitleBar) SyncSoundVolume() {
snd_segs := [][]int{ []int{0,10}, []int{10,30}, []int{30,70},[]int{70,100} }
ge := 0
for i,v in range snd_segs {
for i,v := range snd_segs {
if vol >= v[0] && vol <= v[1] {
ge = i
break
@ -178,7 +188,7 @@ func (self *TitleBar) CheckBatteryStat() {
defer file.Close()
bat_uevent := make([string]string)
bat_uevent := make(map[string]string)
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
@ -195,14 +205,14 @@ func (self *TitleBar) CheckBatteryStat() {
cur_cap := 0
if val, ok := bat_uevent["POWER_SUPPLY_CAPACITY"]; ok {
cur_cap = strings.Atoi(val)
cur_cap,_ = strconv.Atoi(val)
}else {
cur_cap = 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] {
cap_ge = i
break
@ -286,7 +296,7 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
round_corners.MyType = ICON_TYPES["STAT"]
round_corners.Parent = self
round_corners.ImgSurf = MyIconPool.GetImageSurf["roundcorners"]
round_corners.ImgSurf = MyIconPool.GetImgSurf("roundcorners")
round_corners.Adjust(0,0,10,10,0)
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)
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)
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)
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text

View File

@ -6,8 +6,11 @@ import (
"github.com/veandco/go-sdl2/sdl"
"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/font"
)
@ -17,7 +20,7 @@ type UntitledIcon struct {
PosY int
Width int
Height int
Words [2]string
Words []string
FontObj *ttf.Font
BG *sdl.Surface
Color *color.Color
@ -29,18 +32,19 @@ func NewUntitledIcon() *UntitledIcon {
u := &UntitledIcon{}
u.Width = 80
u.Height = 80
u.Words = [2]string{"G","s"}
u.Words = []string{"G","s"}
u.FontObj = Fonts["varela40"]
u.Color = &color.Color{83,83,83,255}
u.BlankPng = SkinMap("gameshell/blank.png")
return u
}
func (self *UntitledIcon) Init() {
self.BG = image.Load(self.BlankPng)
)
}
func (self *UntitledIcon) SetWords( TwoWords ...string) {
if len(TwoWords) == 1 {
@ -59,7 +63,7 @@ func (self *UntitledIcon) Draw() {
w_ := self.Text.W
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)
}
}

View File

@ -14,15 +14,16 @@ import (
func SkinMap(orig_file_or_dir string) string {
DefaultSkin := "default"
ret := ""
skin_dir_prefix:= "skin/"
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 {
ret = strings.Replace(orig_file_or_dir,"..", "../skin/"+DefaultSkin)
ret = strings.Replace(orig_file_or_dir,"..", skin_dir_prefix + DefaultSkin,-1)
}
}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 {
ret = "../skin/"+DefaultSkin+"/sysgo/"+orig_file_or_dir
ret = skin_dir_prefix+DefaultSkin+"/sysgo/"+orig_file_or_dir
}
}

View File

@ -1,7 +0,0 @@
## easings [![GoDoc](https://godoc.org/github.com/gen2brain/raylib-go/easings?status.svg)](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/).
![screenshot](https://goo.gl/crzRrH)

View File

View File

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