Skip to content

Commit

Permalink
render: rename default NewText and NewStrText -> NewStringerText and …
Browse files Browse the repository at this point in the history
…NewText
  • Loading branch information
200sc committed Jun 25, 2021
1 parent 4bd2226 commit 63c9e5b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/error-scene/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func main() {
// go to an unknown scene
controller.ErrorScene = "error"
controller.AddScene("typo", scene.Scene{Start: func(ctx *scene.Context) {
ctx.DrawStack.Draw(render.NewStrText("Real scene", 100, 100))
ctx.DrawStack.Draw(render.NewText("Real scene", 100, 100))
}})
controller.AddScene("error", scene.Scene{Start: func(ctx *scene.Context) {
ctx.DrawStack.Draw(render.NewStrText("Error scene", 100, 100))
ctx.DrawStack.Draw(render.NewText("Error scene", 100, 100))
}})

controller.Init("typpo")
Expand Down
2 changes: 1 addition & 1 deletion examples/joystick-viz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func main() {
latestInput := new(string)
*latestInput = "Latest Input: None"
ctx.DrawStack.Draw(render.NewStrPtrText(latestInput, 10, 460), 4)
ctx.DrawStack.Draw(render.NewStrText("Space to Vibrate", 10, 440), 4)
ctx.DrawStack.Draw(render.NewText("Space to Vibrate", 10, 440), 4)
ctx.EventHandler.GlobalBind(event.InputChange, func(_ event.CID, payload interface{}) int {
input := payload.(oak.InputType)
switch input {
Expand Down
2 changes: 1 addition & 1 deletion examples/keyboard-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var keys = map[rune]struct{}{}

func main() {
oak.AddScene("keyboard-test", scene.Scene{Start: func(*scene.Context) {
kRenderable := render.NewStrText("", 40, 40)
kRenderable := render.NewText("", 40, 40)
render.Draw(kRenderable, 0)
event.GlobalBind(key.Down, func(_ event.CID, k interface{}) int {
kValue := k.(key.Event)
Expand Down
2 changes: 1 addition & 1 deletion examples/screenopts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (

func main() {
oak.AddScene("demo", scene.Scene{Start: func(*scene.Context) {
txt := render.NewStrText("Press F to toggle fullscreen. Press B to toggle borderless.", 50, 50)
txt := render.NewText("Press F to toggle fullscreen. Press B to toggle borderless.", 50, 50)
render.Draw(txt)

borderless := borderlessAtStart
Expand Down
6 changes: 3 additions & 3 deletions examples/titlescreen-demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
oak.AddScene("titlescreen", scene.Scene{Start: func(ctx *scene.Context) {

//create text saying titlescreen in placeholder position
titleText := render.NewStrText("titlescreen", 0, 0)
titleText := render.NewText("titlescreen", 0, 0)

//center text along both axes
center(ctx, titleText, Both)
Expand All @@ -49,7 +49,7 @@ func main() {
render.Draw(titleText)

//do the same for the text with button instuctions, but this time Y position is not a placeholder (X still is)
instructionText := render.NewStrText("press Enter to start, or press Q to quit", 0, float64(ctx.Window.Height()*3/4))
instructionText := render.NewText("press Enter to start, or press Q to quit", 0, float64(ctx.Window.Height()*3/4))
//this time we only center the X axis, otherwise it would overlap titleText
center(ctx, instructionText, X)
render.Draw(instructionText)
Expand Down Expand Up @@ -80,7 +80,7 @@ func main() {
//we have to get the visual part specificaly, and not the whole thing.
render.Draw(player.R)

controlsText := render.NewStrText("WASD to move, ESC to return to titlescreen", 5, 20)
controlsText := render.NewText("WASD to move, ESC to return to titlescreen", 5, 20)
//we draw the text on layer 1 (instead of the default layer 0)
//because we want it to show up above the player
render.Draw(controlsText, 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/zooming/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (

func main() {
oak.AddScene("demo", scene.Scene{Start: func(*scene.Context) {
render.Draw(render.NewStrText("Controls: Arrow keys", 500, 440))
render.Draw(render.NewText("Controls: Arrow keys", 500, 440))

// Get an image that we will illustrate zooming with later
s, err := render.LoadSprite("assets", filepath.Join("raw", "mona-lisa.jpg"))
Expand Down
8 changes: 4 additions & 4 deletions render/defaultfont.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
// so storing the result and calling these functions on the stored Font is
// recommended in cases where performance is a concern.

// NewText creates a text element using the default font.
func NewText(str fmt.Stringer, x, y float64) *Text {
// NewStringerText creates a text element using the default font and a stringer.
func NewStringerText(str fmt.Stringer, x, y float64) *Text {
return DefaultFont().NewStringerText(str, x, y)
}

Expand All @@ -20,8 +20,8 @@ func NewIntText(str *int, x, y float64) *Text {
return DefaultFont().NewIntText(str, x, y)
}

// NewStrText is a helper to take in a string instead of a Stringer for NewText
func NewStrText(str string, x, y float64) *Text {
// NewText is a helper to create a text element with the default font and a string.
func NewText(str string, x, y float64) *Text {
return DefaultFont().NewText(str, x, y)
}

Expand Down
8 changes: 4 additions & 4 deletions render/defaultfont_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

func TestLegacyFont(t *testing.T) {
initTestFont()
if NewText(dummyStringer{}, 0, 0) == nil {
t.Fatalf("NewText failed")
if NewStringerText(dummyStringer{}, 0, 0) == nil {
t.Fatalf("NewStringerText failed")
}
if NewStrText("text", 0, 0) == nil {
t.Fatalf("NewStrText failed")
if NewText("text", 0, 0) == nil {
t.Fatalf("NewText failed")
}
if NewIntText(new(int), 0, 0) == nil {
t.Fatalf("NewIntText failed")
Expand Down

0 comments on commit 63c9e5b

Please sign in to comment.