mirror of
https://github.com/mvvasilev/last_light.git
synced 2025-04-19 12:49:52 +03:00
Move some things around
This commit is contained in:
parent
a56e3d3c91
commit
3b9923a713
10 changed files with 29 additions and 35 deletions
|
@ -2,7 +2,6 @@ package state
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"mvvasilev/last_light/game/model"
|
||||
"mvvasilev/last_light/game/ui/menu"
|
||||
|
||||
|
@ -14,7 +13,7 @@ type InventoryScreenState struct {
|
|||
exitMenu bool
|
||||
|
||||
inventoryMenu *menu.PlayerInventoryMenu
|
||||
selectedInventorySlot engine1.Position
|
||||
selectedInventorySlot engine.Position
|
||||
|
||||
player *model.Player
|
||||
|
||||
|
@ -27,7 +26,7 @@ func CreateInventoryScreenState(player *model.Player, prevState PausableState) *
|
|||
|
||||
iss.prevState = prevState
|
||||
iss.player = player
|
||||
iss.selectedInventorySlot = engine1.PositionAt(0, 0)
|
||||
iss.selectedInventorySlot = engine.PositionAt(0, 0)
|
||||
iss.exitMenu = false
|
||||
iss.inventoryMenu = menu.CreatePlayerInventoryMenu(43, 0, player.Inventory(), tcell.StyleDefault, tcell.StyleDefault.Background(tcell.ColorDarkSlateGray))
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package state
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"mvvasilev/last_light/game/ui"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
@ -50,13 +49,13 @@ func NewMainMenuState() *MainMenuState {
|
|||
func (mms *MainMenuState) OnInput(e *tcell.EventKey) {
|
||||
if e.Key() == tcell.KeyDown {
|
||||
mms.buttons[mms.currButtonSelected].Unhighlight()
|
||||
mms.currButtonSelected = engine1.LimitIncrement(mms.currButtonSelected, 2)
|
||||
mms.currButtonSelected = engine.LimitIncrement(mms.currButtonSelected, 2)
|
||||
mms.buttons[mms.currButtonSelected].Highlight()
|
||||
}
|
||||
|
||||
if e.Key() == tcell.KeyUp {
|
||||
mms.buttons[mms.currButtonSelected].Unhighlight()
|
||||
mms.currButtonSelected = engine1.LimitDecrement(mms.currButtonSelected, 0)
|
||||
mms.currButtonSelected = engine.LimitDecrement(mms.currButtonSelected, 0)
|
||||
mms.buttons[mms.currButtonSelected].Highlight()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package state
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"mvvasilev/last_light/game/ui"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
@ -68,13 +67,13 @@ func (pg *PauseGameState) OnInput(e *tcell.EventKey) {
|
|||
|
||||
if e.Key() == tcell.KeyDown {
|
||||
pg.buttons[pg.currButtonSelected].Unhighlight()
|
||||
pg.currButtonSelected = engine1.LimitIncrement(pg.currButtonSelected, 1)
|
||||
pg.currButtonSelected = engine.LimitIncrement(pg.currButtonSelected, 1)
|
||||
pg.buttons[pg.currButtonSelected].Highlight()
|
||||
}
|
||||
|
||||
if e.Key() == tcell.KeyUp {
|
||||
pg.buttons[pg.currButtonSelected].Unhighlight()
|
||||
pg.currButtonSelected = engine1.LimitDecrement(pg.currButtonSelected, 0)
|
||||
pg.currButtonSelected = engine.LimitDecrement(pg.currButtonSelected, 0)
|
||||
pg.buttons[pg.currButtonSelected].Highlight()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package state
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"mvvasilev/last_light/game/model"
|
||||
"mvvasilev/last_light/game/world"
|
||||
|
||||
|
@ -26,7 +25,7 @@ type PlayingState struct {
|
|||
func BeginPlayingState() *PlayingState {
|
||||
s := new(PlayingState)
|
||||
|
||||
mapSize := engine1.SizeOf(128, 128)
|
||||
mapSize := engine.SizeOf(128, 128)
|
||||
|
||||
dungeonLevel := world.CreateBSPDungeonMap(mapSize.Width(), mapSize.Height(), 4)
|
||||
|
||||
|
@ -37,11 +36,15 @@ func BeginPlayingState() *PlayingState {
|
|||
genTable[0.051] = model.ItemTypeLongsword()
|
||||
genTable[0.052] = model.ItemTypeKey()
|
||||
|
||||
itemTiles := world.SpawnItems(dungeonLevel.Rooms(), 0.025, genTable)
|
||||
itemTiles := world.SpawnItems(dungeonLevel.Rooms(), 0.01, genTable)
|
||||
|
||||
itemLevel := world.CreateEmptyDungeonLevel(mapSize.Width(), mapSize.Height())
|
||||
|
||||
for _, it := range itemTiles {
|
||||
if !dungeonLevel.TileAt(it.Position().XY()).Passable() {
|
||||
continue
|
||||
}
|
||||
|
||||
itemLevel.SetTileAt(it.Position().X(), it.Position().Y(), it)
|
||||
}
|
||||
|
||||
|
@ -58,9 +61,9 @@ func BeginPlayingState() *PlayingState {
|
|||
s.entityMap.AddEntity(s.player, '@', tcell.StyleDefault)
|
||||
|
||||
s.viewport = engine.CreateViewport(
|
||||
engine1.PositionAt(0, 0),
|
||||
engine.PositionAt(0, 0),
|
||||
dungeonLevel.PlayerSpawnPoint(),
|
||||
engine1.SizeOf(80, 24),
|
||||
engine.SizeOf(80, 24),
|
||||
tcell.StyleDefault,
|
||||
)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package ui
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/gdamore/tcell/v2/views"
|
||||
|
@ -45,11 +44,11 @@ func (b *UIBorderedButton) MoveTo(x int, y int) {
|
|||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (b *UIBorderedButton) Position() engine1.Position {
|
||||
func (b *UIBorderedButton) Position() engine.Position {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (b *UIBorderedButton) Size() engine1.Size {
|
||||
func (b *UIBorderedButton) Size() engine.Size {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package ui
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
@ -41,11 +40,11 @@ func (t *UILabel) MoveTo(x int, y int) {
|
|||
t.text = engine.CreateText(x, y, int(t.text.Size().Width()), int(t.Size().Height()), t.text.Content(), t.text.Style())
|
||||
}
|
||||
|
||||
func (t *UILabel) Position() engine1.Position {
|
||||
func (t *UILabel) Position() engine.Position {
|
||||
return t.text.Position()
|
||||
}
|
||||
|
||||
func (t *UILabel) Size() engine1.Size {
|
||||
func (t *UILabel) Size() engine.Size {
|
||||
return t.text.Size()
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package menu
|
|||
import (
|
||||
"fmt"
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"mvvasilev/last_light/game/model"
|
||||
"mvvasilev/last_light/game/ui"
|
||||
|
||||
|
@ -27,7 +26,7 @@ type PlayerInventoryMenu struct {
|
|||
selectedItem *engine.ArbitraryDrawable
|
||||
help *ui.UILabel
|
||||
|
||||
selectedInventorySlot engine1.Position
|
||||
selectedInventorySlot engine.Position
|
||||
}
|
||||
|
||||
func CreatePlayerInventoryMenu(x, y int, playerInventory *model.EquippedInventory, style tcell.Style, highlightStyle tcell.Style) *PlayerInventoryMenu {
|
||||
|
@ -138,11 +137,11 @@ func (pim *PlayerInventoryMenu) MoveTo(x int, y int) {
|
|||
|
||||
}
|
||||
|
||||
func (pim *PlayerInventoryMenu) Position() engine1.Position {
|
||||
func (pim *PlayerInventoryMenu) Position() engine.Position {
|
||||
return pim.inventoryMenu.Position()
|
||||
}
|
||||
|
||||
func (pim *PlayerInventoryMenu) Size() engine1.Size {
|
||||
func (pim *PlayerInventoryMenu) Size() engine.Size {
|
||||
return pim.inventoryMenu.Size()
|
||||
}
|
||||
|
||||
|
@ -156,7 +155,7 @@ func (pim *PlayerInventoryMenu) UniqueId() uuid.UUID {
|
|||
|
||||
func (pim *PlayerInventoryMenu) SelectSlot(x, y int) {
|
||||
pim.inventoryGrid.Unhighlight()
|
||||
pim.selectedInventorySlot = engine1.PositionAt(x, y)
|
||||
pim.selectedInventorySlot = engine.PositionAt(x, y)
|
||||
pim.inventoryGrid.Highlight(pim.selectedInventorySlot)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package ui
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
|
@ -85,11 +84,11 @@ func (sb *UISimpleButton) MoveTo(x int, y int) {
|
|||
sb.text = engine.CreateText(x, y, int(utf8.RuneCountInString(sb.text.Content())), 1, sb.text.Content(), sb.highlightedStyle)
|
||||
}
|
||||
|
||||
func (sb *UISimpleButton) Position() engine1.Position {
|
||||
func (sb *UISimpleButton) Position() engine.Position {
|
||||
return sb.text.Position()
|
||||
}
|
||||
|
||||
func (sb *UISimpleButton) Size() engine1.Size {
|
||||
func (sb *UISimpleButton) Size() engine.Size {
|
||||
return sb.text.Size()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,15 +2,14 @@ package ui
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
type UIElement interface {
|
||||
MoveTo(x, y int)
|
||||
Position() engine1.Position
|
||||
Size() engine1.Size
|
||||
Position() engine.Position
|
||||
Size() engine.Size
|
||||
Input(e *tcell.EventKey)
|
||||
|
||||
engine.Drawable
|
||||
|
|
|
@ -2,7 +2,6 @@ package ui
|
|||
|
||||
import (
|
||||
"mvvasilev/last_light/engine"
|
||||
engine1 "mvvasilev/last_light/engine"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
@ -45,12 +44,12 @@ func (w *UIWindow) MoveTo(x int, y int) {
|
|||
|
||||
}
|
||||
|
||||
func (w *UIWindow) Position() engine1.Position {
|
||||
func (w *UIWindow) Position() engine.Position {
|
||||
return w.box.Position()
|
||||
}
|
||||
|
||||
func (w *UIWindow) Size() engine1.Size {
|
||||
return engine1.SizeOf(0, 0)
|
||||
func (w *UIWindow) Size() engine.Size {
|
||||
return engine.SizeOf(0, 0)
|
||||
}
|
||||
|
||||
func (w *UIWindow) Draw(v views.View) {
|
||||
|
|
Loading…
Add table
Reference in a new issue