dev menu
This commit is contained in:
parent
1ba189697f
commit
c6d3997e6f
@ -148,8 +148,17 @@ func main() {
|
||||
}).MakeList(),
|
||||
)
|
||||
|
||||
screenMgr.AddScreen("devmenu", screens.NewDevmenuScreen(
|
||||
mw,
|
||||
screenMgr,
|
||||
&State,
|
||||
types.NewCenteredRect(mw.Rect, 70, 25),
|
||||
true,
|
||||
).SetBgColor("#ef305c70").
|
||||
SetFgColor("white"),
|
||||
)
|
||||
|
||||
screenMgr.SetScreenByName("title")
|
||||
screenMgr.SetScreenByName("title")
|
||||
|
||||
//fixme
|
||||
//player := &mob.Player{
|
||||
|
@ -82,3 +82,8 @@ func (l *Level) SetAllInvisible() {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Level) SetAllVisible() {
|
||||
for idx, _ := range l.Tiles {
|
||||
l.Tiles[idx].Visible = true
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ func DefaultGen(ctx util.ClientCtx,l *gamemap.Level) (*gamemap.Level, []*gamemap
|
||||
rng := util.NewRNG()
|
||||
|
||||
//load prefabs
|
||||
//pfLoader := gamemap.NewPrefabLoader(ctx)
|
||||
//pfRooms := pfLoader.PrefabRoomsList()
|
||||
pfLoader := gamemap.NewPrefabLoader(ctx)
|
||||
pfRooms := pfLoader.PrefabRoomsList()
|
||||
|
||||
|
||||
//fill with walls
|
||||
@ -61,17 +61,17 @@ func DefaultGen(ctx util.ClientCtx,l *gamemap.Level) (*gamemap.Level, []*gamemap
|
||||
var fillage types.RectFill
|
||||
fillage = fges[rng.GetWeightedEntity(map[int]int{1: 10, 2: 1})]
|
||||
var newRoom *gamemap.Room
|
||||
//if rng.Range(0, 5) > 3 {
|
||||
if rng.Range(0, 5) == 1 {
|
||||
//prefab
|
||||
newRoom = &pfRooms[0]
|
||||
} else {
|
||||
newRoom = gamemap.NewRandomRectRoom(
|
||||
rng,
|
||||
rng.Range(minRoomSize, maxRoomSize),
|
||||
rng.Range(minRoomSize, maxRoomSize),
|
||||
fillage,
|
||||
)
|
||||
//} else {
|
||||
// prefab
|
||||
// newRoom = &pfRooms[0]
|
||||
//}
|
||||
}
|
||||
where := types.Coords{
|
||||
rng.Range(1, l.W -2 - newRoom.W),
|
||||
rng.Range(1, l.H - 2 - newRoom.H),
|
||||
|
@ -81,7 +81,7 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
|
||||
Geometry: make([]func()*Tile, rawPrefab.Size.X*rawPrefab.Size.Y),
|
||||
Mobs: make([]mob.Mob, rawPrefab.Size.X*rawPrefab.Size.Y),
|
||||
Items: make([]items.Carried, rawPrefab.Size.X*rawPrefab.Size.Y),
|
||||
Connectors: make([]types.Coords, rawPrefab.Size.X*rawPrefab.Size.Y),
|
||||
Connectors: make([]types.Coords, 0),
|
||||
}
|
||||
//make geometry
|
||||
var f func() *Tile
|
||||
@ -94,6 +94,9 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
|
||||
for i:=0; i < room.W; i++ {
|
||||
ok := false
|
||||
shortName := currentTileLegend[string(str[i])]
|
||||
if shortName == "" {
|
||||
continue
|
||||
}
|
||||
if shortName == "any" {
|
||||
continue
|
||||
}
|
||||
|
95
engine/screens/devmenu.go
Normal file
95
engine/screens/devmenu.go
Normal file
@ -0,0 +1,95 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"lab.zaar.be/thefish/alchemyst-go/ui/mainwindow"
|
||||
)
|
||||
|
||||
type DevmenuScreen struct {
|
||||
mw *mainwindow.MainWindow
|
||||
scm *types.ScreenManager
|
||||
state *gamestate.GameState
|
||||
|
||||
*types.Rect
|
||||
|
||||
renderParent bool
|
||||
|
||||
bgColor string
|
||||
fgColor string
|
||||
}
|
||||
|
||||
func NewDevmenuScreen(mw *mainwindow.MainWindow, scm *types.ScreenManager, state *gamestate.GameState, rect *types.Rect, renderParent bool) *DevmenuScreen {
|
||||
return &DevmenuScreen{
|
||||
mw: mw,
|
||||
scm: scm,
|
||||
state: state,
|
||||
|
||||
Rect: rect,
|
||||
renderParent: renderParent,
|
||||
}
|
||||
}
|
||||
|
||||
func (devm *DevmenuScreen) SetBgColor(color string) *DevmenuScreen {
|
||||
devm.bgColor = color
|
||||
return devm
|
||||
}
|
||||
|
||||
func (devm *DevmenuScreen) SetFgColor(color string) *DevmenuScreen {
|
||||
devm.fgColor = color
|
||||
return devm
|
||||
}
|
||||
|
||||
func (devm *DevmenuScreen) UseEcs() bool { return false }
|
||||
func (devm *DevmenuScreen) Enter() {
|
||||
|
||||
}
|
||||
func (devm *DevmenuScreen) HandleInput(input string) {
|
||||
switch input {
|
||||
case "i":
|
||||
level := devm.state.Level
|
||||
for idx, _ := range level.Tiles {
|
||||
level.Tiles[idx].Visible = false
|
||||
level.Tiles[idx].Explored = false
|
||||
}
|
||||
break
|
||||
case "v":
|
||||
level := devm.state.Level
|
||||
for idx, _ := range level.Tiles {
|
||||
level.Tiles[idx].Visible = true
|
||||
level.Tiles[idx].Explored = true
|
||||
}
|
||||
fmt.Printf("making everything visible!")
|
||||
break
|
||||
case "Escape":
|
||||
fallthrough
|
||||
case "Space":
|
||||
devm.scm.SetScreen(devm.scm.PreviousScreen)
|
||||
break
|
||||
}
|
||||
}
|
||||
func (devm *DevmenuScreen) Exit() {
|
||||
if devm.renderParent {
|
||||
devm.scm.PreviousScreen.Render()
|
||||
}
|
||||
menuLayer := devm.mw.GetLayer("menu")
|
||||
menuLayer.ClearRect(devm.Rect)
|
||||
bgLayer := devm.mw.GetLayer("menubg")
|
||||
bgLayer.ClearRect(devm.Rect)
|
||||
|
||||
}
|
||||
func (devm *DevmenuScreen) Render() {
|
||||
menuLayer := devm.mw.GetLayer("menu")
|
||||
menuLayer.ClearRect(devm.Rect)
|
||||
bgLayer := devm.mw.GetLayer("menubg")
|
||||
bgLayer.ClearRect(devm.Rect)
|
||||
bgLayer.WithColor(devm.bgColor).NewWindow(devm.Rect).NoBorder()
|
||||
|
||||
menuLayer.WithColor(devm.fgColor).PrintInside(
|
||||
devm.Rect,
|
||||
"v - all visible\ni - all invisible",
|
||||
1,
|
||||
)
|
||||
|
||||
}
|
@ -65,6 +65,10 @@ func (ts *GameScreen) HandleInput(input string) {
|
||||
case "Shift+/":
|
||||
ts.scm.SetScreenByName("help")
|
||||
break
|
||||
case "Shift+z":
|
||||
ts.scm.SetScreenByName("devmenu")
|
||||
break
|
||||
|
||||
case "i":
|
||||
ts.scm.SetScreenByName("inventory")
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user