GLK: FROTZ: Implement PageUp/PageDn scrolling of desc area in Beyond Zork
This commit is contained in:
parent
f218400d3b
commit
7a21e23603
6 changed files with 58 additions and 16 deletions
|
@ -194,6 +194,13 @@ void GlkInterface::initialize() {
|
||||||
|
|
||||||
// Add any sound folder or zip
|
// Add any sound folder or zip
|
||||||
addSound();
|
addSound();
|
||||||
|
|
||||||
|
// For Beyond Zork the Page Up/Down keys are remapped to scroll the description area,
|
||||||
|
// since the arrow keys the original used are in use now for cycling prior commands
|
||||||
|
if (_storyId == BEYOND_ZORK) {
|
||||||
|
uint32 KEYCODES[2] = { keycode_PageUp, keycode_PageDown };
|
||||||
|
glk_set_terminators_line_event(gos_lower, KEYCODES, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlkInterface::addSound() {
|
void GlkInterface::addSound() {
|
||||||
|
@ -588,6 +595,16 @@ zchar GlkInterface::os_read_line(int max, zchar *buf, int timeout, int width, in
|
||||||
reset_status_ht();
|
reset_status_ht();
|
||||||
curr_status_ht = 0;
|
curr_status_ht = 0;
|
||||||
|
|
||||||
|
if (ev.val2) {
|
||||||
|
// Line terminator specified, so return it
|
||||||
|
if (_storyId == BEYOND_ZORK && ev.val2 == keycode_PageUp)
|
||||||
|
return ZC_ARROW_UP;
|
||||||
|
else if (_storyId == BEYOND_ZORK && ev.val2 == keycode_PageDown)
|
||||||
|
return ZC_ARROW_DOWN;
|
||||||
|
|
||||||
|
return ev.val2;
|
||||||
|
}
|
||||||
|
|
||||||
return ZC_RETURN;
|
return ZC_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ uint GlkAPI::glk_gestalt_ext(uint id, uint val, uint *arr, uint arrlen) {
|
||||||
return g_conf->_sound;
|
return g_conf->_sound;
|
||||||
|
|
||||||
case gestalt_LineTerminatorKey:
|
case gestalt_LineTerminatorKey:
|
||||||
return Window::checkTerminator(val);
|
return Window::checkBasicTerminators(val);
|
||||||
|
|
||||||
case gestalt_Timer:
|
case gestalt_Timer:
|
||||||
case gestalt_Unicode:
|
case gestalt_Unicode:
|
||||||
|
|
|
@ -762,9 +762,10 @@ void TextBufferWindow::cancelLineEvent(Event *ev) {
|
||||||
_lineRequest = false;
|
_lineRequest = false;
|
||||||
_lineRequestUni = false;
|
_lineRequestUni = false;
|
||||||
if (_lineTerminators) {
|
if (_lineTerminators) {
|
||||||
free(_lineTerminators);
|
delete[] _lineTerminators;
|
||||||
_lineTerminators = nullptr;
|
_lineTerminators = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
_inBuf = nullptr;
|
_inBuf = nullptr;
|
||||||
_inMax = 0;
|
_inMax = 0;
|
||||||
|
|
||||||
|
@ -1246,15 +1247,10 @@ void TextBufferWindow::acceptReadLine(uint32 arg) {
|
||||||
if (_height < 2)
|
if (_height < 2)
|
||||||
_scrollPos = 0;
|
_scrollPos = 0;
|
||||||
|
|
||||||
if (_scrollPos || arg == keycode_PageUp || arg == keycode_MouseWheelUp) {
|
|
||||||
acceptScroll(arg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_inBuf)
|
if (!_inBuf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_lineTerminators && checkTerminator(arg)) {
|
if (_lineTerminators && checkTerminators(arg)) {
|
||||||
for (cx = _lineTerminators; *cx; cx++) {
|
for (cx = _lineTerminators; *cx; cx++) {
|
||||||
if (*cx == arg) {
|
if (*cx == arg) {
|
||||||
acceptLine(arg);
|
acceptLine(arg);
|
||||||
|
@ -1263,6 +1259,11 @@ void TextBufferWindow::acceptReadLine(uint32 arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_scrollPos || arg == keycode_PageUp || arg == keycode_MouseWheelUp) {
|
||||||
|
acceptScroll(arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
// History keys (up and down)
|
// History keys (up and down)
|
||||||
case keycode_Up:
|
case keycode_Up:
|
||||||
|
@ -1442,10 +1443,16 @@ void TextBufferWindow::acceptLine(uint32 keycode) {
|
||||||
_attr = _origAttr;
|
_attr = _origAttr;
|
||||||
|
|
||||||
if (_lineTerminators) {
|
if (_lineTerminators) {
|
||||||
uint val2 = keycode;
|
if (keycode == keycode_Return)
|
||||||
if (val2 == keycode_Return)
|
keycode = 0;
|
||||||
val2 = 0;
|
else
|
||||||
g_vm->_events->store(evtype_LineInput, this, len, val2);
|
// TODO: Currently particularly for Beyond Zork, we don't echo a newline
|
||||||
|
// for line terminators, allowing description area scrolling to not keep adding
|
||||||
|
// blank lines in the command area. In the future I may need to make it configurable
|
||||||
|
// when I see if any other line terminators need to have a newline
|
||||||
|
_echoLineInput = false;
|
||||||
|
|
||||||
|
g_vm->_events->store(evtype_LineInput, this, len, keycode);
|
||||||
free(_lineTerminators);
|
free(_lineTerminators);
|
||||||
_lineTerminators = nullptr;
|
_lineTerminators = nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -465,7 +465,7 @@ void TextGridWindow::acceptReadLine(uint32 arg) {
|
||||||
if (!_inBuf)
|
if (!_inBuf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_lineTerminators && checkTerminator(arg)) {
|
if (_lineTerminators && checkTerminators(arg)) {
|
||||||
const uint32 *cx;
|
const uint32 *cx;
|
||||||
for (cx = _lineTerminators; *cx; cx++) {
|
for (cx = _lineTerminators; *cx; cx++) {
|
||||||
if (*cx == arg) {
|
if (*cx == arg) {
|
||||||
|
|
|
@ -342,6 +342,10 @@ void Windows::inputScrollFocus() {
|
||||||
void Windows::inputHandleKey(uint key) {
|
void Windows::inputHandleKey(uint key) {
|
||||||
if (_moreFocus) {
|
if (_moreFocus) {
|
||||||
inputMoreFocus();
|
inputMoreFocus();
|
||||||
|
} else if (_focusWin && (_focusWin->_lineRequest || _focusWin->_lineRequestUni) &&
|
||||||
|
_focusWin->checkTerminators(key)) {
|
||||||
|
// WORKAROUND: Do line terminators checking first. This was first needed for Beyond Zork,
|
||||||
|
// since it needs the Page Up/Down keys to scroll the description area rathern than the buffer area
|
||||||
} else {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case keycode_Tab:
|
case keycode_Tab:
|
||||||
|
@ -633,7 +637,7 @@ const WindowStyle *Window::getStyles() const {
|
||||||
|
|
||||||
void Window::setTerminatorsLineEvent(const uint32 *keycodes, uint count) {
|
void Window::setTerminatorsLineEvent(const uint32 *keycodes, uint count) {
|
||||||
if (dynamic_cast<TextBufferWindow *>(this) || dynamic_cast<TextGridWindow *>(this)) {
|
if (dynamic_cast<TextBufferWindow *>(this) || dynamic_cast<TextGridWindow *>(this)) {
|
||||||
delete _lineTerminatorsBase;
|
delete[] _lineTerminatorsBase;
|
||||||
_lineTerminatorsBase = nullptr;
|
_lineTerminatorsBase = nullptr;
|
||||||
|
|
||||||
if (!keycodes || count == 0) {
|
if (!keycodes || count == 0) {
|
||||||
|
@ -651,7 +655,7 @@ void Window::setTerminatorsLineEvent(const uint32 *keycodes, uint count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::checkTerminator(uint32 ch) {
|
bool Window::checkBasicTerminators(uint32 ch) {
|
||||||
if (ch == keycode_Escape)
|
if (ch == keycode_Escape)
|
||||||
return true;
|
return true;
|
||||||
else if (ch >= keycode_Func12 && ch <= keycode_Func1)
|
else if (ch >= keycode_Func12 && ch <= keycode_Func1)
|
||||||
|
@ -660,6 +664,18 @@ bool Window::checkTerminator(uint32 ch) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Window::checkTerminators(uint32 ch) {
|
||||||
|
if (checkBasicTerminators(ch))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (uint idx = 0; idx < _termCt; ++idx) {
|
||||||
|
if (_lineTerminatorsBase[idx] == ch)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::imageDraw(uint image, uint align, int val1, int val2) {
|
bool Window::imageDraw(uint image, uint align, int val1, int val2) {
|
||||||
if (!g_conf->_graphics)
|
if (!g_conf->_graphics)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -396,7 +396,7 @@ public:
|
||||||
|
|
||||||
gidispatch_rock_t _dispRock;
|
gidispatch_rock_t _dispRock;
|
||||||
public:
|
public:
|
||||||
static bool checkTerminator(uint32 ch);
|
static bool checkBasicTerminators(uint32 ch);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -498,6 +498,8 @@ public:
|
||||||
|
|
||||||
int acceptScroll(uint arg);
|
int acceptScroll(uint arg);
|
||||||
|
|
||||||
|
bool checkTerminators(uint32 ch);
|
||||||
|
|
||||||
void setTerminatorsLineEvent(const uint32 *keycodes, uint count);
|
void setTerminatorsLineEvent(const uint32 *keycodes, uint count);
|
||||||
|
|
||||||
virtual void acceptReadLine(uint32 arg);
|
virtual void acceptReadLine(uint32 arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue