mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-05 08:07:51 -05:00
Fix terminal taking input when not visible, fix timescale command (#294)
This commit is contained in:
parent
0c618bd31b
commit
a04d2389c3
@ -130,15 +130,12 @@ func (t *terminal) advance(elapsed float64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool {
|
func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool {
|
||||||
maxOutputIndex := d2common.MaxInt(0, len(t.outputHistory)-t.lineCount)
|
if t.visState == termVisHiding || t.visState == termVisHidden && event.Key == d2input.KeyGraveAccent {
|
||||||
|
|
||||||
if t.visState == termVisHiding || t.visState == termVisHidden {
|
|
||||||
if event.Key == d2input.KeyGraveAccent {
|
|
||||||
t.show()
|
t.show()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// When terminal is not visible, only d2input.KeyGraveAccent is consumed.
|
if !t.isVisible() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +149,8 @@ func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxOutputIndex := d2common.MaxInt(0, len(t.outputHistory)-t.lineCount)
|
||||||
|
|
||||||
if event.Key == d2input.KeyHome {
|
if event.Key == d2input.KeyHome {
|
||||||
t.outputIndex = maxOutputIndex
|
t.outputIndex = maxOutputIndex
|
||||||
return true
|
return true
|
||||||
@ -224,11 +223,14 @@ func (t *terminal) OnKeyDown(event d2input.KeyEvent) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// When terminal is visible, all keys are consumed.
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *terminal) OnKeyChars(event d2input.KeyCharsEvent) bool {
|
func (t *terminal) OnKeyChars(event d2input.KeyCharsEvent) bool {
|
||||||
|
if !t.isVisible() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var handled bool
|
var handled bool
|
||||||
for _, c := range event.Chars {
|
for _, c := range event.Chars {
|
||||||
if c != '`' {
|
if c != '`' {
|
||||||
|
@ -54,6 +54,7 @@ func Initialize(loadingSpr *d2ui.Sprite) error {
|
|||||||
if timeScale <= 0 {
|
if timeScale <= 0 {
|
||||||
d2term.OutputError("invalid time scale value")
|
d2term.OutputError("invalid time scale value")
|
||||||
} else {
|
} else {
|
||||||
|
singleton.timeScale = timeScale
|
||||||
d2term.OutputInfo("timescale changed from %f to %f", singleton.timeScale, timeScale)
|
d2term.OutputInfo("timescale changed from %f to %f", singleton.timeScale, timeScale)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user