Skip to content

Commit

Permalink
Fixes #10
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Smart <[email protected]>
  • Loading branch information
mcred committed Feb 20, 2020
1 parent 98ff6c5 commit 61ded03
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
8 changes: 8 additions & 0 deletions internal/app/common/Collectibles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package common

func Gold() Attribute {
return Attribute{0x294, 4, true}
}
func GoldDisplay() Attribute {
return Attribute{0x19C, 4, true}
}
22 changes: 16 additions & 6 deletions internal/app/storage/Slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ type Slot struct {

func (s *Slot) GetValueByAttribute(a common.Attribute) int {
b := s.Data[a.Location:(a.Location+a.Bytes)]
if a.Bytes == 1 {
return int(b[0])
if a.Reversed {
switch a.Bytes {
case 2:
return int(binary.LittleEndian.Uint16(b))
case 4:
return int(binary.LittleEndian.Uint32(b))
default:
return int(b[0])
}
} else {
if a.Reversed {
return int(binary.LittleEndian.Uint16(b))
} else {
return int(binary.BigEndian.Uint16(b))
switch a.Bytes {
case 2:
return int(binary.BigEndian.Uint16(b))
case 4:
return int(binary.LittleEndian.Uint32(b))
default:
return int(b[0])
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion internal/app/ui/Form.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ func createPartyForm(s *storage.Slot) *fyne.Container {
s1 := createPosSelect(characters.GetCharacterNames(), common.First(), common.FirstDisplay(), s)
s2 := createPosSelect(characters.GetCharacterNames(), common.Second(), common.SecondDisplay(), s)
s3 := createPosSelect(characters.GetCharacterNames(), common.Third(), common.ThirdDisplay(), s)
e1 := widget.NewEntry()
e1.SetPlaceHolder(strconv.Itoa(s.GetValueByAttribute(common.Gold())))
e1.OnChanged = func(v string) {
i, _ := strconv.Atoi(v)
s.SetValueAtLocation(common.Gold(), i)
s.SetValueAtLocation(common.GoldDisplay(), i)
}
return fyne.NewContainerWithLayout(layout.NewHBoxLayout(),
widget.NewLabel("Party"), s1, s2, s3)
widget.NewLabel("Party"), s1, s2, s3, widget.NewLabel("Gold"), e1)
}

func createCharacterBox(b *widget.Box, c characters.Character, w inventory.Inventory, s *storage.Slot, window fyne.Window) {
Expand Down

0 comments on commit 61ded03

Please sign in to comment.