Skip to content

Commit e34e730

Browse files
committed
Merge branch 'hints'
2 parents 833dc7c + ab7321d commit e34e730

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+27513
-160
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ gotta go fast.
1414
- `Home` resets the tracker and reloads its configuration from file, only works
1515
when the timer is stopped (not paused).
1616

17+
## Hint tracker
18+
1. Press the key corresponding to your hint type (WotH, Barren, Sometimes,
19+
Always)
20+
2. Type your text.
21+
3. Press `Enter`
22+
23+
- `w` to enter a _WotH_ Hint (green background, fuzzy location search)
24+
- `b` to enter a _Barren_ Hint (red background, fuzzy location search)
25+
- `s` to enter a _Sometimes_ Hint (blue background, freeform text)
26+
- `a` to enter a _Always_ Hint (yellow background)
27+
28+
As _Always Hints_ have a fixed slot, they get special treatment. The text you input
29+
is parsed as the slot name until the first space, then your text. eg. If you
30+
get _Nocturne of Shadows_ on _Ocarina of Time_ you might press `a` to start the
31+
prompt then `oot = nocturne` then `Enter`.
32+
1733
## Item tracker
1834
### Keyboard
1935
**Ivan must be focused for keyboard input to work.**

app.go

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,53 @@ package main
22

33
import (
44
"errors"
5-
"image"
65
"ivan/timer"
76
"ivan/tracker"
87

98
"github.com/hajimehoshi/ebiten"
109
"github.com/hajimehoshi/ebiten/inpututil"
1110
)
1211

13-
const (
14-
width = tracker.Width
15-
height = tracker.Height + timer.Height
16-
)
12+
const configPath = "assets/config.json"
1713

1814
var errCloseApp = errors.New("user requested app close")
1915

2016
type App struct {
2117
tracker *tracker.Tracker
2218
timer *timer.Timer
19+
config config
2320
}
2421

2522
func NewApp() (*App, error) {
26-
timer, err := timer.New(image.Point{0, tracker.Height})
23+
config, err := loadConfig(configPath)
2724
if err != nil {
2825
return nil, err
2926
}
3027

31-
tracker, err := tracker.New("assets/config.json")
28+
size := config.windowSize()
29+
ebiten.SetWindowSize(size.X, size.Y)
30+
ebiten.SetWindowPosition(1920-size.X, 0)
31+
32+
timer, err := timer.New(config.Dimensions.Timer)
33+
if err != nil {
34+
return nil, err
35+
}
36+
37+
tracker, err := tracker.New(
38+
config.Dimensions.ItemTracker,
39+
config.Dimensions.HintTracker,
40+
config.Items,
41+
config.ZoneItemMap,
42+
config.Locations,
43+
)
3244
if err != nil {
3345
return nil, err
3446
}
3547

3648
return &App{
3749
tracker: tracker,
3850
timer: timer,
51+
config: config,
3952
}, nil
4053
}
4154

@@ -44,24 +57,47 @@ func (app *App) Update(screen *ebiten.Image) error {
4457

4558
switch {
4659
case inpututil.IsKeyJustPressed(ebiten.KeyEscape):
47-
if !app.timer.IsRunning() {
60+
if !app.timer.IsRunning() && !app.tracker.EatInput() {
4861
return errCloseApp
4962
}
63+
app.tracker.Cancel()
64+
5065
case inpututil.IsKeyJustPressed(ebiten.KeyHome):
5166
if !app.timer.IsRunning() {
52-
app.tracker.Reset()
67+
config, err := loadConfig(configPath)
68+
if err != nil {
69+
return err
70+
}
71+
app.config = config
72+
app.tracker.Reset(app.config.Items, app.config.ZoneItemMap)
5373
}
74+
75+
case inpututil.IsKeyJustPressed(ebiten.KeyEnter):
76+
app.tracker.Submit()
77+
5478
case inpututil.IsKeyJustPressed(ebiten.KeySpace):
55-
app.timer.Toggle()
79+
if app.tracker.EatInput() {
80+
app.tracker.Input([]rune(" "))
81+
} else {
82+
app.timer.Toggle()
83+
}
84+
5685
case inpututil.IsKeyJustPressed(ebiten.KeyDelete):
5786
app.timer.Reset()
87+
88+
case inpututil.IsKeyJustPressed(ebiten.KeyBackspace):
89+
app.tracker.Backspace()
90+
5891
case inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft):
5992
app.tracker.ClickLeft(ebiten.CursorPosition())
93+
6094
case inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight):
6195
app.tracker.ClickRight(ebiten.CursorPosition())
96+
6297
case wheel != 0:
6398
x, y := ebiten.CursorPosition()
6499
app.tracker.Wheel(x, y, wheel > 0)
100+
65101
default:
66102
app.tracker.Input(ebiten.InputChars())
67103
}

assets/background-help.png

1.33 KB
Loading

assets/background-help.xcf

-23.7 KB
Binary file not shown.

assets/background.png

7.11 KB
Loading

assets/background.xcf

35.7 KB
Binary file not shown.

assets/config.json

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
{
2-
"ZoneItems": [
2+
"Dimensions": {
3+
"ItemTracker": {
4+
"Min": {"X": 0, "Y": 0},
5+
"Max": {"X": 294, "Y": 378}
6+
},
7+
"Timer": {
8+
"Min": {"X": 0, "Y": 378},
9+
"Max": {"X": 294, "Y": 462}
10+
},
11+
"HintTracker": {
12+
"Min": {"X": 0, "Y": 462},
13+
"Max": {"X": 294, "Y": 672}
14+
}
15+
},
16+
"ZoneItemMap": [
317
[
418
"Kokiri Boots", "Iron Boots", "Hover Boots",
519
"Kokiri Tunic", "Goron Tunic", "Zora Tunic",
@@ -44,6 +58,43 @@
4458
"Song of Storms"
4559
]
4660
],
61+
"Locations": [
62+
"Bottom of the Well",
63+
"Death Mountain Crater",
64+
"Death Mountain Trail",
65+
"Deku Tree",
66+
"Desert Colossus",
67+
"Dodongo's Cavern",
68+
"Fire Temple",
69+
"Forest Temple",
70+
"Ganon's Castle",
71+
"Gerudo Training Grounds",
72+
"Gerudo Valley",
73+
"Gerudo's Fortress",
74+
"Goron City",
75+
"Graveyard",
76+
"Haunted Wasteland",
77+
"Hyrule Castle",
78+
"Hyrule Field",
79+
"Ice Cavern",
80+
"Jabu Jabu's Belly",
81+
"Kakariko Village",
82+
"Kokiri Forest",
83+
"Lake Hylia",
84+
"Links House",
85+
"Lon Lon Ranch",
86+
"Lost Woods",
87+
"Market",
88+
"Outside Ganon's Castle",
89+
"Sacred Forest Meadow",
90+
"Shadow Temple",
91+
"Spirit Temple",
92+
"Temple of Time",
93+
"Water Temple",
94+
"Zora's Domain",
95+
"Zora's Fountain",
96+
"Zora's River"
97+
],
4798
"Items": [
4899
{
49100
"Name": "Deku Stick",
@@ -600,8 +651,7 @@
600651
"X": 0,
601652
"Y": 294,
602653
"SheetX": 70,
603-
"SheetY": 175,
604-
"Enabled": true
654+
"SheetY": 175
605655
},
606656
{
607657
"Name": "Goron Tunic",
@@ -622,8 +672,7 @@
622672
"X": 0,
623673
"Y": 336,
624674
"SheetX": 175,
625-
"SheetY": 175,
626-
"Enabled": true
675+
"SheetY": 175
627676
},
628677
{
629678
"Name": "Iron Boots",
@@ -645,7 +694,6 @@
645694
"Y": 168,
646695
"SheetX": 35,
647696
"SheetY": 245,
648-
"Enabled": true,
649697
"CountMax": 100,
650698
"CountStep": 5
651699
},

assets/home-screenshot.png

18.5 KB
Loading

assets/home-screenshot.xcf

91.3 KB
Binary file not shown.

config.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"image"
6+
"ivan/tracker"
7+
"os"
8+
)
9+
10+
type config struct {
11+
Items []tracker.Item
12+
ZoneItemMap [9][9]string
13+
Locations []string // woth/barren "simple" locations
14+
Dimensions struct {
15+
ItemTracker image.Rectangle
16+
Timer image.Rectangle
17+
HintTracker image.Rectangle
18+
}
19+
}
20+
21+
func (c config) windowSize() image.Point {
22+
var ret image.Rectangle
23+
for _, v := range []image.Rectangle{
24+
c.Dimensions.ItemTracker,
25+
c.Dimensions.Timer,
26+
c.Dimensions.HintTracker,
27+
} {
28+
ret = ret.Union(v)
29+
}
30+
31+
return ret.Size()
32+
}
33+
34+
func loadConfig(path string) (config, error) {
35+
f, err := os.Open(path)
36+
if err != nil {
37+
return config{}, err
38+
}
39+
defer f.Close()
40+
41+
var ret config
42+
dec := json.NewDecoder(f)
43+
if err := dec.Decode(&ret); err != nil {
44+
return config{}, err
45+
}
46+
47+
return ret, nil
48+
}

0 commit comments

Comments
 (0)