-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
texto en Furia2D-Engine !!!!!
- Loading branch information
Showing
8 changed files
with
241 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
package engine | ||
|
||
import ( | ||
rl "github.com/gen2brain/raylib-go/raylib" | ||
"github.com/tawesoft/golib/v2/dialog" | ||
) | ||
|
||
var ( | ||
/* [ON] [ON] [ON] [ON] [ON]->DRAW NO | ||
ui objects: UiButton - UiText - UiTextBox - UiSelect - UiMessageBox ->ALLS TYPES OF MESSAGEBOX | ||
*/ | ||
|
||
//text | ||
ui_text []*UiText | ||
) | ||
|
||
type UiText struct { | ||
text string | ||
pos Position | ||
size uint16 | ||
font *string | ||
color Color | ||
hide bool | ||
} | ||
|
||
func NewUiText(text string, pos Position, size uint16) *UiText { | ||
p := &UiText{ | ||
text: text, | ||
pos: pos, | ||
size: size, | ||
font: nil, | ||
color: NewColor2(255, 0, 0), | ||
hide: false, | ||
} | ||
p = p.add() | ||
return p | ||
} | ||
|
||
func NewUiTextWithFont(text string, font string, pos Position, size uint16) *UiText { | ||
p := &UiText{ | ||
text: text, | ||
pos: pos, | ||
size: size, | ||
font: &font, | ||
color: NewColor2(255, 0, 0), | ||
hide: false, | ||
} | ||
p = p.add() | ||
return p | ||
} | ||
func (text *UiText) Hide() { | ||
//rl.DrawRectangle | ||
text.hide = true | ||
} | ||
func (text *UiText) Show() { | ||
text.hide = false | ||
} | ||
func (text *UiText) Draw() { | ||
if text.hide == false { | ||
|
||
if text.font == nil { | ||
|
||
rl.DrawText(text.text, text.pos.X, text.pos.Y, int32(text.size), ConvertColor(text.color)) | ||
} else { | ||
rl.DrawTextEx(rl.LoadFont(text.FontName()), text.text, rl.NewVector2(float32(text.pos.X), float32(text.pos.Y)), float32(text.size), 0.5, ConvertColor(text.color)) | ||
} | ||
} | ||
} | ||
func (text *UiText) add() *UiText { | ||
ui_text = append(ui_text, text) | ||
return ui_text[len(ui_text)-1] | ||
} | ||
func (text *UiText) SetColor(nColor Color) { | ||
text.color = nColor | ||
} | ||
func (text *UiText) SetColor2(r, g, b, a uint8) { | ||
text.color = NewColor(r, g, b, a) | ||
} | ||
func (text *UiText) SetColor3(r, g, b uint8) { | ||
text.color = NewColor2(r, g, b) | ||
} | ||
func (text *UiText) Color() Color { | ||
return text.color | ||
} | ||
func (text *UiText) SetFontName(font string) { | ||
if font == "" || font == "default" { | ||
text.font = nil | ||
} else { | ||
text.font = &font | ||
} | ||
} | ||
|
||
func (text *UiText) FontName() string { | ||
if text.font == nil { | ||
return "default" | ||
} else { | ||
return *text.font | ||
} | ||
} | ||
func (text *UiText) SetSize(nSize uint16) { | ||
text.size = nSize | ||
} | ||
func (text *UiText) Size() uint16 { | ||
return text.size | ||
} | ||
func (text *UiText) SetPosition(nPos Position) { | ||
text.pos = nPos | ||
} | ||
func (text *UiText) Position() Position { | ||
return text.pos | ||
} | ||
func (text *UiText) SetText(nText string) { | ||
text.text = nText | ||
} | ||
func (text *UiText) Text() string { | ||
return text.text | ||
} | ||
|
||
type UiMessageBoxAlert struct { | ||
title string | ||
message string | ||
} | ||
|
||
func ShowMessageBoxAlert(title, message string) { | ||
NewMessageBoxAlert(title, message).Show() | ||
} | ||
func NewMessageBoxAlert(title, message string) *UiMessageBoxAlert { | ||
return &UiMessageBoxAlert{ | ||
message: message, | ||
title: title, | ||
} | ||
} | ||
func (mb *UiMessageBoxAlert) Show() { | ||
dialog.Message{ | ||
Title: mb.title, | ||
Format: mb.message, | ||
Icon: dialog.IconWarning, | ||
}.Raise() | ||
} | ||
|
||
//info | ||
|
||
type UiMessageBoxInfo struct { | ||
title string | ||
message string | ||
} | ||
|
||
func ShowMessageBoxInfo(title, message string) { | ||
NewMessageBoxInfo(title, message).Show() | ||
} | ||
func NewMessageBoxInfo(title, message string) *UiMessageBoxInfo { | ||
return &UiMessageBoxInfo{ | ||
message: message, | ||
title: title, | ||
} | ||
} | ||
func (mb *UiMessageBoxInfo) Show() { | ||
dialog.Message{ | ||
Title: mb.title, | ||
Format: mb.message, | ||
Icon: dialog.IconInfo, | ||
}.Raise() | ||
} | ||
|
||
type UiMessageBoxError struct { | ||
title string | ||
message string | ||
} | ||
|
||
func ShowMessageBoxError(title, message string) { | ||
NewMessageBoxError(title, message).Show() | ||
} | ||
func NewMessageBoxError(title, message string) *UiMessageBoxError { | ||
return &UiMessageBoxError{ | ||
message: message, | ||
title: title, | ||
} | ||
} | ||
func (mb *UiMessageBoxError) Show() { | ||
dialog.Message{ | ||
Title: mb.title, | ||
Format: mb.message, | ||
Icon: dialog.IconError, | ||
}.Raise() | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
e "github.com/Troxsoft/Furia2D-Engine/engine" | ||
) | ||
|
||
var text *e.UiText | ||
var contador int = 0 | ||
|
||
func main() { | ||
e.InitGame("Ejemplos de Gui en Furia2D-Engine :)", e.NewSize(500, 400), func(ge *e.GameEvent) { | ||
|
||
e.ShowMessageBoxAlert("alerta", "empieza la diversion") | ||
e.ShowMessageBoxError(":(", "mala") | ||
e.ShowMessageBoxInfo(":)", "fue una broma") | ||
text = e.NewUiText(fmt.Sprint(contador), e.NewPosition(50, 50), 20) | ||
|
||
//fmt.Println(obj.F) | ||
}, | ||
func(ge *e.GameEvent) { | ||
contador += 1 | ||
text.SetText(fmt.Sprint(contador)) | ||
if contador > 400 { | ||
text.Hide() | ||
} | ||
if contador > 800 { | ||
text.Show() | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= | ||
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= | ||
github.com/ebitengine/purego v0.6.0-alpha.2 h1:lYSvMtNBEjNGAzqPC5WP7bHUOxkFU3L+JZMdxK7krkw= | ||
github.com/ebitengine/purego v0.6.0-alpha.2/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= | ||
github.com/gen2brain/raylib-go/raylib v0.0.0-20231123174446-48309e2407b7 h1:qu+EOzSIbZHZdlahUAZRGAjyiSjzSNEnIiucIEHCKYU= | ||
github.com/gen2brain/raylib-go/raylib v0.0.0-20231123174446-48309e2407b7/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE= | ||
github.com/tawesoft/golib/v2 v2.10.0 h1:uvA5Cy+UV6NHrf3Qwg1+2Uvz6eKVW1t+KrJ9gZYSjag= | ||
github.com/tawesoft/golib/v2 v2.10.0/go.mod h1:jGw0nDuOLpji2TW5QfSQLcWnZ4WtS4TizzRuXu3hZ/Y= | ||
golang.org/x/exp v0.0.0-20221208152030-732eee02a75a h1:4iLhBPcpqFmylhnkbY3W0ONLUYYkDAW9xMFLfxgsvCw= | ||
golang.org/x/exp v0.0.0-20221208152030-732eee02a75a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= | ||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= | ||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= | ||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= |