mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-11 05:36:12 +00:00
WAGE: Implemented text console callback
This commit is contained in:
parent
c9d3b7210e
commit
6f03947bc9
@ -143,6 +143,9 @@ static void cursorTimerHandler(void *refCon) {
|
||||
gui->_cursorDirty = true;
|
||||
}
|
||||
|
||||
static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui);
|
||||
static void consoleWindowCallback(WindowClick click, Common::Event &event, void *gui);
|
||||
|
||||
Gui::Gui(WageEngine *engine) {
|
||||
_engine = engine;
|
||||
_scene = NULL;
|
||||
@ -190,7 +193,10 @@ Gui::Gui(WageEngine *engine) {
|
||||
_menu = new Menu(this);
|
||||
|
||||
_sceneWindow = _wm.add(false);
|
||||
_sceneWindow->setCallback(sceneWindowCallback, this);
|
||||
|
||||
_consoleWindow = _wm.add(true);
|
||||
_consoleWindow->setCallback(consoleWindowCallback, this);
|
||||
}
|
||||
|
||||
Gui::~Gui() {
|
||||
@ -303,6 +309,9 @@ void Gui::drawScene() {
|
||||
_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
|
||||
}
|
||||
|
||||
static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui) {
|
||||
}
|
||||
|
||||
// Render console
|
||||
void Gui::drawConsole() {
|
||||
if (!_consoleDirty && !_consoleFullRedraw && !_bordersDirty && !_sceneDirty)
|
||||
@ -314,6 +323,22 @@ void Gui::drawConsole() {
|
||||
_consoleWindow->setDirty(true);
|
||||
}
|
||||
|
||||
static void consoleWindowCallback(WindowClick click, Common::Event &event, void *g) {
|
||||
Gui *gui = (Gui *)g;
|
||||
|
||||
if (click == kBorderScrollUp || click == kBorderScrollDown) {
|
||||
int textFullSize = gui->getLinesSize() * gui->getConsoleLineHeight() + gui->getConsoleTextAreaHeight();
|
||||
float scrollPos = (float)gui->getScrollPos() / textFullSize;
|
||||
float scrollSize = (float)gui->getConsoleTextAreaHeight() / textFullSize;
|
||||
|
||||
gui->_consoleWindow->setScroll(scrollPos, scrollSize);
|
||||
|
||||
warning("pos: %f size: %f", scrollPos, scrollSize);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h) {
|
||||
Common::Rect r(x, y, x + w + 1, y + h + 1);
|
||||
|
||||
|
@ -114,6 +114,11 @@ public:
|
||||
|
||||
bool builtInFonts() { return _builtInFonts; }
|
||||
|
||||
uint getScrollPos() { return _scrollPos; }
|
||||
uint getLinesSize() { return _lines.size(); }
|
||||
int getConsoleLineHeight() { return _consoleLineHeight; }
|
||||
int getConsoleTextAreaHeight() { return _consoleTextArea.height(); }
|
||||
|
||||
private:
|
||||
void drawScene();
|
||||
void drawConsole();
|
||||
@ -150,6 +155,9 @@ public:
|
||||
|
||||
bool _menuDirty;
|
||||
|
||||
MacWindow *_sceneWindow;
|
||||
MacWindow *_consoleWindow;
|
||||
|
||||
private:
|
||||
Graphics::ManagedSurface _console;
|
||||
Menu *_menu;
|
||||
@ -181,8 +189,6 @@ private:
|
||||
int _inputTextLineNum;
|
||||
|
||||
MacWindowManager _wm;
|
||||
MacWindow *_sceneWindow;
|
||||
MacWindow *_consoleWindow;
|
||||
};
|
||||
|
||||
} // End of namespace Wage
|
||||
|
@ -294,6 +294,7 @@ bool MacWindow::processEvent(Common::Event &event) {
|
||||
}
|
||||
|
||||
void MacWindow::mouseDown(Common::Event &event) {
|
||||
_innerDims.debugPrint();
|
||||
if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
|
||||
if (!_callback)
|
||||
return;
|
||||
@ -303,6 +304,7 @@ void MacWindow::mouseDown(Common::Event &event) {
|
||||
}
|
||||
|
||||
WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
|
||||
warning("click: %d", click);
|
||||
|
||||
if (click == kBorderNone)
|
||||
return;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
Graphics::ManagedSurface *getSurface() { return &_surface; }
|
||||
void setTitle(Common::String &title) { _title = title; }
|
||||
void setHighlight(WindowClick highlightedPart) { _highlightedPart = highlightedPart; }
|
||||
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
|
||||
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; _borderIsDirty = true; }
|
||||
void setDirty(bool dirty) { _contentIsDirty = dirty; }
|
||||
int getId() { return _id; }
|
||||
bool processEvent(Common::Event &event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user