Merge branch 'sdl2'

This commit is contained in:
jacob1 2018-05-28 11:49:35 -04:00
commit ce6c913c88
63 changed files with 1225 additions and 1162 deletions

View File

@ -231,7 +231,7 @@ def findLibs(env, conf):
if msvc:
libChecks = ['shell32', 'wsock32', 'user32', 'Advapi32', 'ws2_32']
if GetOption('static'):
libChecks += ['libcmt', 'dxguid']
libChecks += ['imm32', 'version', 'Ole32', 'OleAut32']
for i in libChecks:
if not conf.CheckLib(i):
FatalError("Error: some windows libraries not found or not installed, make sure your compiler is set up correctly")
@ -239,30 +239,29 @@ def findLibs(env, conf):
if not conf.CheckLib('mingw32') or not conf.CheckLib('ws2_32'):
FatalError("Error: some windows libraries not found or not installed, make sure your compiler is set up correctly")
if not GetOption('renderer') and not conf.CheckLib('SDLmain'):
FatalError("libSDLmain not found or not installed")
if not GetOption('renderer') and not conf.CheckLib('SDL2main'):
FatalError("libSDL2main not found or not installed")
if not GetOption('renderer'):
#Look for SDL
runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD"
if platform == "Darwin" and conf.CheckFramework("SDL"):
runSdlConfig = False
elif not conf.CheckLib("SDL"):
FatalError("SDL development library not found or not installed")
#Look for SDL
runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD"
if False and platform == "Darwin" and conf.CheckFramework("SDL"):
runSdlConfig = False
elif not conf.CheckLib("SDL2"):
FatalError("SDL development library not found or not installed")
if runSdlConfig:
try:
env.ParseConfig('sdl-config --cflags')
if GetOption('static'):
env.ParseConfig('sdl-config --static-libs')
else:
env.ParseConfig('sdl-config --libs')
except:
pass
if runSdlConfig:
try:
env.ParseConfig('sdl2-config --cflags')
if GetOption('static'):
env.ParseConfig('sdl2-config --static-libs')
else:
env.ParseConfig('sdl2-config --libs')
except:
pass
#look for SDL.h
if not GetOption('renderer') and not conf.CheckCHeader('SDL.h'):
if conf.CheckCHeader('SDL/SDL.h'):
if not conf.CheckCHeader('SDL2.h'):
if conf.CheckCHeader('SDL2/SDL.h'):
env.Append(CPPDEFINES=["SDL_INC"])
else:
FatalError("SDL.h not found")
@ -505,8 +504,6 @@ if GetOption('opengl') or GetOption('opengl-renderer'):
if GetOption('renderer'):
env.Append(CPPDEFINES=['RENDERER'])
else:
env.Append(CPPDEFINES=['USE_SDL'])
if GetOption('font'):
env.Append(CPPDEFINES=['FONTEDITOR'])
@ -555,8 +552,8 @@ if platform == "Windows":
envCopy = env.Clone()
envCopy.Append(CCFLAGS='-mstackrealign')
sources += envCopy.Object('src/simulation/Gravity.cpp')
elif platform == "Darwin":
sources += ["src/SDLMain.m"]
#elif platform == "Darwin":
# sources += ["src/SDLMain.m"]
#Program output name

File diff suppressed because one or more lines are too long

View File

@ -20,4 +20,3 @@
*/
#pragma once
extern const unsigned char app_icon[];
extern const unsigned char app_icon_bitmap[];

View File

@ -1,7 +1,16 @@
import sys
from PIL import Image
image = Image.open(sys.argv[1])
with open(sys.argv[1], "rb") as icon:
output = ""
formatted = []
for pixel in image.getdata():
formatted.extend("0x{0:02X}".format(byte) for byte in pixel)
for i in range(len(formatted)/16 + 1):
print(", ".join(formatted[i*16:(i+1)*16]) + ",")
"""with open(sys.argv[1], "rb") as icon:
icondata = icon.read()
output = ["0x{0:02X}".format(ord(byte)) for byte in icondata]
for line in range(len(output)/16+1):
print(", ".join(output[line*16:(line+1)*16])+",")
print(", ".join(output[line*16:(line+1)*16])+",")"""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -4,6 +4,4 @@ void EngineProcess();
void ClipboardPush(ByteString text);
ByteString ClipboardPull();
int GetModifiers();
bool LoadWindowPosition(int scale);
void SetCursorEnabled(int enabled);
unsigned int GetTicks();

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#if defined(USE_SDL) && defined(_MSC_VER) && (_MSC_VER >= 1900)
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
#include <cstdio>

View File

@ -1,19 +1,15 @@
#ifdef USE_SDL
#ifdef SDL_INC
#include "SDL/SDL.h"
#include "SDL2/SDL.h"
#else
#include "SDL.h"
#endif
#ifdef INCLUDE_SYSWM
#if defined(WIN) || defined(LIN)
#if defined(WIN)
#ifdef SDL_INC
#include <SDL/SDL_syswm.h>
#include <SDL2/SDL_syswm.h>
#else
#include <SDL_syswm.h>
#endif
#endif // WIN || LIN
#endif // WIN
#endif // INCLUDE_SYSWM
#endif // USE_SDL

View File

@ -11,5 +11,5 @@ public:
unsigned int debugID;
virtual void Draw() {}
// currentMouse doesn't belong but I don't want to create more hooks at the moment
virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse) { return true; }
virtual bool KeyPress(int key, int scan, bool shift, bool ctrl, bool alt, ui::Point currentMouse) { return true; }
};

View File

@ -57,7 +57,7 @@ void ParticleDebug::Debug(int mode, int x, int y)
}
}
bool ParticleDebug::KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse)
bool ParticleDebug::KeyPress(int key, int scan, bool shift, bool ctrl, bool alt, ui::Point currentMouse)
{
if (key == 'f')
{

View File

@ -12,7 +12,7 @@ class ParticleDebug : public DebugInfo
public:
ParticleDebug(unsigned int id, Simulation * sim, GameModel * model);
void Debug(int mode, int x, int y);
virtual bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt, ui::Point currentMouse);
virtual bool KeyPress(int key, int scan, bool shift, bool ctrl, bool alt, ui::Point currentMouse);
virtual ~ParticleDebug();
};

View File

@ -239,8 +239,10 @@ void ColourPickerActivity::OnMouseUp(int x, int y, unsigned button)
}
}
void ColourPickerActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void ColourPickerActivity::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (key == SDLK_TAB)
{
if (rValue->IsFocused())

View File

@ -36,7 +36,7 @@ public:
virtual void OnMouseMove(int x, int y, int dx, int dy);
virtual void OnMouseDown(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnTryExit(ExitMethod method);
ColourPickerActivity(ui::Colour initialColour, ColourPickedCallback * callback = NULL);
virtual ~ColourPickerActivity();

View File

@ -24,17 +24,16 @@ ConsoleView::ConsoleView():
commandField->SetBorder(false);
}
void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if ((scan == SDL_SCANCODE_GRAVE && key != '~') || key == SDLK_ESCAPE)
{
if (!repeat)
doClose = true;
return;
}
switch(key)
{
case SDLK_ESCAPE:
case '`':
if (character != '~')
c->CloseConsole();
else
Window::DoKeyPress(key, character, shift, ctrl, alt);
break;
case SDLK_RETURN:
case SDLK_KP_ENTER:
c->EvaluateCommand(commandField->GetText());
@ -48,11 +47,19 @@ void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
c->PreviousCommand();
break;
default:
Window::DoKeyPress(key, character, shift, ctrl, alt);
Window::DoKeyPress(key, scan, repeat, shift, ctrl, alt);
break;
}
}
void ConsoleView::DoTextInput(String text)
{
if (text == "~")
doClose = false;
if (!doClose)
Window::DoTextInput(text);
}
void ConsoleView::NotifyPreviousCommandsChanged(ConsoleModel * sender)
{
for (size_t i = 0; i < commandList.size(); i++)
@ -97,6 +104,16 @@ void ConsoleView::OnDraw()
g->draw_line(Position.X, Position.Y+Size.Y, Position.X+Size.X, Position.Y+Size.Y, 255, 255, 255, 200);
}
ConsoleView::~ConsoleView() {
void ConsoleView::OnTick(float dt)
{
if (doClose)
{
c->CloseConsole();
doClose = false;
}
}
ConsoleView::~ConsoleView()
{
}

View File

@ -17,10 +17,13 @@ class ConsoleView: public ui::Window {
ConsoleController * c;
ui::Textbox * commandField;
std::vector<ui::Label*> commandList;
bool doClose = false;
public:
ConsoleView();
virtual void OnDraw();
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void OnDraw() override;
void OnTick(float dt) override;
void DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
void DoTextInput(String text) override;
void AttachController(ConsoleController * c_) { c = c_; }
void NotifyPreviousCommandsChanged(ConsoleModel * sender);
void NotifyCurrentCommandChanged(ConsoleModel * sender);

View File

@ -219,8 +219,10 @@ void ElementSearchActivity::OnTick(float dt)
}
}
void ElementSearchActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void ElementSearchActivity::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
switch (key)
{
case SDLK_KP_ENTER:
@ -245,8 +247,10 @@ void ElementSearchActivity::OnKeyPress(int key, Uint16 character, bool shift, bo
}
}
void ElementSearchActivity::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void ElementSearchActivity::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
switch (key)
{
case SDLK_LSHIFT:

View File

@ -33,8 +33,8 @@ public:
void SetActiveTool(int selectionState, Tool * tool);
virtual ~ElementSearchActivity();
virtual void OnTick(float dt);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnDraw();
virtual void ToolTip(ui::Point senderPosition, String ToolTip);
};

View File

@ -93,6 +93,7 @@ public:
virtual void ControllerExit()
{
cc->gameModel->UpdateQuickOptions();
Client::Ref().WritePrefs();
}
};
@ -713,9 +714,11 @@ bool GameController::MouseWheel(int x, int y, int d)
return commandInterface->OnMouseWheel(x, y, d);
}
bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
bool ret = commandInterface->OnKeyPress(key, character, shift, ctrl, alt);
bool ret = commandInterface->OnKeyPress(key, scan, repeat, shift, ctrl, alt);
if (repeat)
return ret;
if (ret)
{
Simulation * sim = gameModel->GetSimulation();
@ -783,16 +786,18 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl,
for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
{
if ((*iter)->debugID & debugFlags)
if (!(*iter)->KeyPress(key, character, shift, ctrl, alt, gameView->GetMousePosition()))
if (!(*iter)->KeyPress(key, scan, shift, ctrl, alt, gameView->GetMousePosition()))
ret = false;
}
}
return ret;
}
bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
bool GameController::KeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
bool ret = commandInterface->OnKeyRelease(key, character, shift, ctrl, alt);
bool ret = commandInterface->OnKeyRelease(key, scan, repeat, shift, ctrl, alt);
if (repeat)
return ret;
if (ret)
{
Simulation * sim = gameModel->GetSimulation();

View File

@ -64,8 +64,8 @@ public:
bool MouseDown(int x, int y, unsigned button);
bool MouseUp(int x, int y, unsigned button, char type);
bool MouseWheel(int x, int y, int d);
bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
bool KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
bool KeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
bool KeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
bool MouseTick();
void Tick();
void Exit();

View File

@ -1374,7 +1374,7 @@ void GameView::BeginStampSelection()
buttonTipShow = 120;
}
void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (introText > 50)
{
@ -1400,6 +1400,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
c->TranslateSave(ui::Point(0, 1));
return;
case 'r':
if (repeat)
return;
if (ctrl && shift)
{
//Vertical flip
@ -1419,6 +1421,14 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
}
}
if (repeat)
return;
if (scan == SDL_SCANCODE_GRAVE)
{
c->ShowConsole();
return;
}
switch(key)
{
case SDLK_LALT:
@ -1456,9 +1466,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
case SDLK_TAB: //Tab
c->ChangeBrush();
break;
case '`':
c->ShowConsole();
break;
case 'p':
case SDLK_F2:
if (ctrl)
@ -1657,8 +1664,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
}
void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void GameView::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
switch(key)
{
case SDLK_LALT:
@ -1689,7 +1698,7 @@ void GameView::OnBlur()
drawMode = DrawPoints;
c->MouseUp(0, 0, 0, 1); // tell lua that mouse is up (even if it really isn't)
if (GetModifiers())
c->KeyRelease(0, 0, false, false, false);
c->KeyRelease(0, 0, false, false, false, false);
}
void GameView::OnTick(float dt)
@ -1823,16 +1832,16 @@ void GameView::DoMouseWheel(int x, int y, int d)
Window::DoMouseWheel(x, y, d);
}
void GameView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void GameView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(c->KeyPress(key, character, shift, ctrl, alt))
Window::DoKeyPress(key, character, shift, ctrl, alt);
if (c->KeyPress(key, scan, repeat, shift, ctrl, alt))
Window::DoKeyPress(key, scan, repeat, shift, ctrl, alt);
}
void GameView::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void GameView::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(c->KeyRelease(key, character, shift, ctrl, alt))
Window::DoKeyRelease(key, character, shift, ctrl, alt);
if(c->KeyRelease(key, scan, repeat, shift, ctrl, alt))
Window::DoKeyRelease(key, scan, repeat, shift, ctrl, alt);
}
void GameView::DoTick(float dt)

View File

@ -191,8 +191,8 @@ public:
virtual void OnMouseDown(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnTick(float dt);
virtual void OnDraw();
virtual void OnBlur();
@ -204,8 +204,8 @@ public:
virtual void DoMouseDown(int x, int y, unsigned button);
virtual void DoMouseUp(int x, int y, unsigned button);
virtual void DoMouseWheel(int x, int y, int d);
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
class MenuAction;
class ToolAction;

View File

@ -23,7 +23,7 @@ public:
PropertyWindow(PropertyTool *tool_, Simulation *sim);
void SetProperty();
virtual void OnDraw();
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnTryExit(ExitMethod method);
virtual ~PropertyWindow() {}
class OkayAction: public ui::ButtonAction
@ -217,7 +217,7 @@ void PropertyWindow::OnDraw()
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);
}
void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void PropertyWindow::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (key == SDLK_UP)
property->SetOption(property->GetOption().second-1);

View File

@ -27,8 +27,8 @@ public:
virtual void DoMouseDown(int x, int y, unsigned button);
virtual void DoMouseUp(int x, int y, unsigned button) { if(!signMoving) ui::Window::DoMouseUp(x, y, button); }
virtual void DoMouseWheel(int x, int y, int d) { if(!signMoving) ui::Window::DoMouseWheel(x, y, d); }
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyPress(key, character, shift, ctrl, alt); }
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyRelease(key, character, shift, ctrl, alt); }
virtual void DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyPress(key, scan, repeat, shift, ctrl, alt); }
virtual void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyRelease(key, scan, repeat, shift, ctrl, alt); }
virtual ~SignWindow() {}
virtual void OnTryExit(ui::Window::ExitMethod method);
class OkayAction: public ui::ButtonAction

View File

@ -190,11 +190,15 @@ void Component::Tick(float dt)
{
}
void Component::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Component::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
}
void Component::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Component::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
}
void Component::OnTextInput(String text)
{
}

View File

@ -66,26 +66,6 @@ namespace ui
virtual void OnContextMenuAction(int item);
//UI functions:
/*
void Tick(float dt);
void Draw(const Point& screenPos);
void OnMouseHover(int localx, int localy);
void OnMouseMoved(int localx, int localy, int dx, int dy);
void OnMouseMovedInside(int localx, int localy, int dx, int dy);
void OnMouseEnter(int localx, int localy);
void OnMouseLeave(int localx, int localy);
void OnMouseDown(int x, int y, unsigned int button);
void OnMouseUp(int x, int y, unsigned int button);
void OnMouseClick(int localx, int localy, unsigned int button);
void OnMouseUnclick(int localx, int localy, unsigned int button);
void OnMouseWheel(int localx, int localy, int d);
void OnMouseWheelInside(int localx, int localy, int d);
void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
*/
///
// Called: Every tick.
// Params:
@ -211,7 +191,7 @@ namespace ui
// ctrl: Control key is down.
// alt: Alternate key is down.
///
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
///
// Called: When a key is released.
@ -221,6 +201,8 @@ namespace ui
// ctrl: Control key is released.
// alt: Alternate key is released.
///
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnTextInput(String text);
};
}

View File

@ -17,8 +17,9 @@ Engine::Engine():
FpsLimit(60.0f),
Scale(1),
Fullscreen(false),
Depth3d(0),
FrameIndex(0),
altFullscreen(false),
resizable(false),
lastBuffer(NULL),
prevBuffers(stack<pixel*>()),
windows(stack<Window*>()),
@ -93,6 +94,8 @@ void Engine::ConfirmExit()
void Engine::ShowWindow(Window * window)
{
windowOpenState = 0;
if (state_)
ignoreEvents = true;
if(window->Position.X==-1)
{
window->Position.X = (width_-window->Size.X)/2;
@ -158,6 +161,7 @@ int Engine::CloseWindow()
mousexp_ = mousex_;
mouseyp_ = mousey_;
}
ignoreEvents = true;
return 0;
}
else
@ -199,6 +203,7 @@ void Engine::Tick()
lastTick = Platform::GetTime();
ignoreEvents = false;
/*if(statequeued_ != NULL)
{
if(state_ != NULL)
@ -250,29 +255,35 @@ void Engine::SetFps(float fps)
this->dt = 1.0f;
}
void Engine::onKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Engine::onKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(state_)
state_->DoKeyPress(key, character, shift, ctrl, alt);
if (state_ && !ignoreEvents)
state_->DoKeyPress(key, scan, repeat, shift, ctrl, alt);
}
void Engine::onKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Engine::onKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(state_)
state_->DoKeyRelease(key, character, shift, ctrl, alt);
if (state_ && !ignoreEvents)
state_->DoKeyRelease(key, scan, repeat, shift, ctrl, alt);
}
void Engine::onTextInput(String text)
{
if (state_ && !ignoreEvents)
state_->DoTextInput(text);
}
void Engine::onMouseClick(int x, int y, unsigned button)
{
mouseb_ |= button;
if(state_)
if (state_ && !ignoreEvents)
state_->DoMouseDown(x, y, button);
}
void Engine::onMouseUnclick(int x, int y, unsigned button)
{
mouseb_ &= ~button;
if(state_)
if (state_ && !ignoreEvents)
state_->DoMouseUp(x, y, button);
}
@ -280,7 +291,7 @@ void Engine::onMouseMove(int x, int y)
{
mousex_ = x;
mousey_ = y;
if(state_)
if (state_ && !ignoreEvents)
{
state_->DoMouseMove(x, y, mousex_ - mousexp_, mousey_ - mouseyp_);
}
@ -290,7 +301,7 @@ void Engine::onMouseMove(int x, int y)
void Engine::onMouseWheel(int x, int y, int delta)
{
if(state_)
if (state_ && !ignoreEvents)
state_->DoMouseWheel(x, y, delta);
}
@ -301,6 +312,6 @@ void Engine::onResize(int newWidth, int newHeight)
void Engine::onClose()
{
if(state_)
if (state_)
state_->DoExit();
}

View File

@ -28,8 +28,9 @@ namespace ui
void onMouseClick(int x, int y, unsigned button);
void onMouseUnclick(int x, int y, unsigned button);
void onMouseWheel(int x, int y, int delta);
void onKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void onKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void onKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void onKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void onTextInput(String text);
void onResize(int newWidth, int newHeight);
void onClose();
@ -45,10 +46,12 @@ namespace ui
void SetFullscreen(bool fullscreen) { Fullscreen = fullscreen; }
inline bool GetFullscreen() { return Fullscreen; }
void SetAltFullscreen(bool altFullscreen) { this->altFullscreen = altFullscreen; }
inline bool GetAltFullscreen() { return altFullscreen; }
void SetScale(int scale) { Scale = scale; }
inline int GetScale() { return Scale; }
void Set3dDepth(int depth3d) { Depth3d = depth3d; if (Depth3d) SetCursorEnabled(0); else SetCursorEnabled(1);}
inline int Get3dDepth() { return Depth3d; }
void SetResizable(bool resizable) { this->resizable = resizable; }
inline bool GetResizable() { return resizable; }
void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
inline bool GetFastQuit() {return FastQuit; }
@ -78,10 +81,12 @@ namespace ui
Graphics * g;
int Scale;
bool Fullscreen;
int Depth3d;
unsigned int FrameIndex;
private:
bool altFullscreen;
bool resizable;
float dt;
float fps;
pixel * lastBuffer;
@ -92,6 +97,7 @@ namespace ui
Window* state_;
Point windowTargetPosition;
int windowOpenState;
bool ignoreEvents = false;
bool running_;
bool break_;

View File

@ -20,6 +20,8 @@
slouken@libsdl.org
*/
#include "SDLCompat.h"
#define _SDL_keysym_h
#ifndef _SDL_keysym_h
#define _SDL_keysym_h

View File

@ -229,8 +229,10 @@ void Label::OnMouseUp(int x, int y, unsigned button)
selecting = false;
}
void Label::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Label::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if(ctrl && key == 'c')
{
copySelection();

View File

@ -62,7 +62,7 @@ namespace ui
virtual void OnMouseClick(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);
virtual void OnMouseMoved(int localx, int localy, int dx, int dy);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void Draw(const Point& screenPos);
virtual void Tick(float dt);
};

View File

@ -2,7 +2,7 @@
#ifdef USE_SDL
#ifdef SDL_INC
#include "SDL/SDL_mouse.h"
#include "SDL2/SDL_mouse.h"
#else
#include "SDL_mouse.h"
#endif

View File

@ -175,14 +175,14 @@ void Panel::Tick(float dt)
children[i]->Tick(dt);
}
void Panel::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Panel::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
XOnKeyPress(key, character, shift, ctrl, alt);
XOnKeyPress(key, scan, repeat, shift, ctrl, alt);
}
void Panel::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Panel::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
XOnKeyRelease(key, character, shift, ctrl, alt);
XOnKeyRelease(key, scan, repeat, shift, ctrl, alt);
}
void Panel::OnMouseClick(int localx, int localy, unsigned button)
@ -401,11 +401,11 @@ void Panel::XTick(float dt)
{
}
void Panel::XOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Panel::XOnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
}
void Panel::XOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Panel::XOnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
}

View File

@ -72,34 +72,14 @@ class Component;
void OnMouseUnclick(int localx, int localy, unsigned button);
void OnMouseWheel(int localx, int localy, int d);
void OnMouseWheelInside(int localx, int localy, int d);
void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
protected:
// child components
std::vector<ui::Component*> children;
bool mouseInside;
//UI functions:
/*
void XTick(float dt);
void XDraw(const Point& screenPos);
void XOnMouseHover(int localx, int localy);
void XOnMouseMoved(int localx, int localy, int dx, int dy);
void XOnMouseMovedInside(int localx, int localy, int dx, int dy);
void XOnMouseEnter(int localx, int localy);
void XOnMouseLeave(int localx, int localy);
void XOnMouseDown(int x, int y, unsigned int button);
void XOnMouseUp(int x, int y, unsigned int button);
void XOnMouseClick(int localx, int localy, unsigned int button);
void XOnMouseUnclick(int localx, int localy, unsigned int button);
void XOnMouseWheel(int localx, int localy, int d);
void XOnMouseWheelInside(int localx, int localy, int d);
void XOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void XOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
*/
// Overridable. Called by XComponent::Tick()
virtual void XTick(float dt);
@ -141,10 +121,10 @@ class Component;
virtual void XOnMouseWheelInside(int localx, int localy, int d);
// Overridable. Called by XComponent::OnKeyPress()
virtual void XOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void XOnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
// Overridable. Called by XComponent::OnKeyRelease()
virtual void XOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void XOnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
};
}

View File

@ -251,7 +251,7 @@ void Textbox::pasteIntoSelection()
actionCallback->TextChangedCallback(this);
}
bool Textbox::CharacterValid(Uint16 character)
bool Textbox::CharacterValid(int character)
{
switch(inputType)
{
@ -270,6 +270,15 @@ bool Textbox::CharacterValid(Uint16 character)
return false;
}
// TODO: proper unicode validation
bool Textbox::StringValid(String text)
{
for (String::value_type c : text)
if (!CharacterValid(c))
return false;
return true;
}
void Textbox::Tick(float dt)
{
Label::Tick(dt);
@ -281,29 +290,29 @@ void Textbox::Tick(float dt)
unsigned long time_pls = Platform::GetTime();
if ((keyDown || characterDown) && repeatTime <= time_pls)
{
OnVKeyPress(keyDown, characterDown, false, false, false);
//OnVKeyPress(keyDown, characterDown, false, false, false);
repeatTime = Platform::GetTime()+30;
}
}
void Textbox::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Textbox::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
keyDown = 0;
characterDown = 0;
}
void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Textbox::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
characterDown = character;
characterDown = scan;
keyDown = key;
repeatTime = Platform::GetTime()+300;
OnVKeyPress(key, character, shift, ctrl, alt);
OnVKeyPress(key, scan, repeat, shift, ctrl, alt);
}
void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Textbox::OnVKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
bool changed = false;
if(ctrl && key == 'c' && !masked)
if(ctrl && key == 'c' && !masked && !repeat)
{
copySelection();
return;
@ -313,7 +322,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
pasteIntoSelection();
return;
}
if(ctrl && key == 'x' && !masked && !ReadOnly)
if(ctrl && key == 'x' && !masked && !repeat && !ReadOnly)
{
cutSelection();
return;
@ -406,38 +415,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
ClearSelection();
break;
case SDLK_RETURN:
character = '\n';
default:
if (CharacterValid(character) && !ReadOnly)
{
if (HasSelection())
{
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
return;
backingText.erase(backingText.begin()+getLowerSelectionBound(), backingText.begin()+getHigherSelectionBound());
cursor = getLowerSelectionBound();
}
int regionWidth = Size.X;
if (Appearance.icon)
regionWidth -= 13;
regionWidth -= Appearance.Margin.Left;
regionWidth -= Appearance.Margin.Right;
if ((limit==String::npos || backingText.length() < limit) && (Graphics::textwidth(backingText + character) <= regionWidth || multiline))
{
if (cursor == (int)backingText.length())
{
backingText += character;
}
else
{
backingText.Insert(cursor, character);
}
cursor++;
}
changed = true;
ClearSelection();
}
OnTextInput("\n");
break;
}
}
@ -446,16 +424,23 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
cursor = 0;
backingText = "";
}
if (inputType == Number)
{
//Remove extra preceding 0's
while(backingText[0] == '0' && backingText.length()>1)
backingText.erase(backingText.begin());
}
AfterTextChange(changed);
}
void Textbox::AfterTextChange(bool changed)
{
if (cursor > (int)backingText.length())
cursor = backingText.length();
if (changed)
{
if (inputType == Number)
{
//Remove extra preceding 0's
while(backingText[0] == '0' && backingText.length()>1)
backingText.erase(backingText.begin());
}
if (masked)
{
String maskedText = backingText;
@ -468,10 +453,10 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
}
if(multiline)
if (multiline)
updateMultiline();
updateSelection();
if(multiline)
if (multiline)
TextPosition(textLines);
else
TextPosition(text);
@ -488,6 +473,40 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
actionCallback->TextChangedCallback(this);
}
void Textbox::OnTextInput(String text)
{
if (StringValid(text) && !ReadOnly)
{
if (HasSelection())
{
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
return;
backingText.erase(backingText.begin()+getLowerSelectionBound(), backingText.begin()+getHigherSelectionBound());
cursor = getLowerSelectionBound();
}
int regionWidth = Size.X;
if (Appearance.icon)
regionWidth -= 13;
regionWidth -= Appearance.Margin.Left;
regionWidth -= Appearance.Margin.Right;
if ((limit==String::npos || backingText.length() < limit) && (Graphics::textwidth(backingText + text) <= regionWidth || multiline))
{
if (cursor == (int)backingText.length())
{
backingText += text;
}
else
{
backingText.Insert(cursor, text);
}
cursor++;
}
ClearSelection();
AfterTextChange(true);
}
}
void Textbox::OnMouseClick(int x, int y, unsigned button)
{
@ -551,162 +570,3 @@ void Textbox::Draw(const Point& screenPos)
if(Appearance.icon)
g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon);
}
/*
Textbox::Textbox(Point position, Point size, std::string textboxText):
Component(position, size),
text(textboxText),
actionCallback(NULL),
masked(false),
border(true)
{
SetText(textboxText);
cursor = text.length();
}
Textbox::~Textbox()
{
delete actionCallback;
}
void Textbox::TextPosition()
{
if(cursor)
{
cursorPosition = Graphics::textnwidth((char *)displayText.c_str(), cursor);
}
else
{
cursorPosition = 0;
}
Component::TextPosition(displayText);
}
void Textbox::SetText(std::string text)
{
cursor = text.length();
this->text = text;
this->displayText = text;
TextPosition();
}
void Textbox::SetDisplayText(std::string text)
{
displayText = text;
TextPosition();
}
std::string Textbox::GetText()
{
return text;
}
void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
bool changed = false;
try
{
switch(key)
{
case KEY_HOME:
cursor = 0;
break;
case KEY_END:
cursor = text.length();
break;
case KEY_LEFT:
if(cursor > 0)
cursor--;
break;
case KEY_RIGHT:
if(cursor < text.length())
cursor++;
break;
case KEY_DELETE:
if(text.length() && cursor < text.length())
{
if(ctrl)
text.erase(cursor, text.length()-cursor);
else
text.erase(cursor, 1);
changed = true;
}
break;
case KEY_BACKSPACE:
if(text.length() && cursor > 0)
{
if(ctrl)
{
text.erase(0, cursor);
cursor = 0;
}
else
{
text.erase(cursor-1, 1);
cursor--;
}
changed = true;
}
break;
}
if(character >= ' ' && character < 127)
{
if(cursor == text.length())
{
text += character;
}
else
{
text.insert(cursor, 1, (char)character);
}
cursor++;
changed = true;
}
}
catch(std::out_of_range &e)
{
cursor = 0;
text = "";
}
if(changed)
{
if(masked)
{
char * tempText = new char[text.length()+1];
std::fill(tempText, tempText+text.length(), 0x8d);
tempText[text.length()] = 0;
displayText = std::string(tempText);
delete tempText;
}
else
{
displayText = text;
}
if(actionCallback)
actionCallback->TextChangedCallback(this);
}
TextPosition();
}
void Textbox::Draw(const Point& screenPos)
{
if(!drawn)
{
TextPosition();
drawn = true;
}
Graphics * g = GetGraphics();
if(IsFocused())
{
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);
g->draw_line(screenPos.X+textPosition.X+cursorPosition, screenPos.Y+3, screenPos.X+textPosition.X+cursorPosition, screenPos.Y+12, 255, 255, 255, WINDOWW);
}
else
{
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
}
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, 255, 255, 255, 255);
if(Appearance.icon)
g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon);
}*/

View File

@ -19,6 +19,9 @@ public:
class Textbox : public Label
{
friend class TextboxAction;
void AfterTextChange(bool changed);
public:
bool ReadOnly;
enum ValidInput { All, Multiline, Numeric, Number }; // Numeric doesn't delete trailing 0's
@ -44,16 +47,18 @@ public:
void resetCursorPosition();
void TabFocus();
//Determines if the given character is valid given the input type
bool CharacterValid(Uint16 character);
bool CharacterValid(int character);
bool StringValid(String text);
virtual void Tick(float dt);
virtual void OnContextMenuAction(int item);
virtual void OnMouseClick(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);
virtual void OnMouseMoved(int localx, int localy, int dx, int dy);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnVKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void OnTextInput(String text) override;
virtual void Draw(const Point& screenPos);
protected:

View File

@ -283,7 +283,7 @@ void Window::DoTick(float dt)
finalise();
}
void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
#ifdef DEBUG
if (key == SDLK_TAB && ctrl)
@ -374,11 +374,11 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a
if (focusedComponent_ != NULL)
{
if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnKeyPress(key, character, shift, ctrl, alt);
focusedComponent_->OnKeyPress(key, scan, repeat, shift, ctrl, alt);
}
if (!stop)
OnKeyPress(key, character, shift, ctrl, alt);
OnKeyPress(key, scan, repeat, shift, ctrl, alt);
if (key == SDLK_ESCAPE)
OnTryExit(Escape);
@ -390,7 +390,7 @@ void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool a
finalise();
}
void Window::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void Window::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
#ifdef DEBUG
if(debugMode)
@ -400,11 +400,30 @@ void Window::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool
if (focusedComponent_ != NULL)
{
if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnKeyRelease(key, character, shift, ctrl, alt);
focusedComponent_->OnKeyRelease(key, scan, repeat, shift, ctrl, alt);
}
if (!stop)
OnKeyRelease(key, character, shift, ctrl, alt);
OnKeyRelease(key, scan, repeat, shift, ctrl, alt);
if (destruct)
finalise();
}
void Window::DoTextInput(String text)
{
#ifdef DEBUG
if (debugMode)
return;
#endif
//on key unpress
if (focusedComponent_ != NULL)
{
if (focusedComponent_->Enabled && focusedComponent_->Visible)
focusedComponent_->OnTextInput(text);
}
if (!stop)
OnTextInput(text);
if (destruct)
finalise();
}

View File

@ -65,8 +65,9 @@ namespace ui
virtual void DoMouseDown(int x, int y, unsigned button);
virtual void DoMouseUp(int x, int y, unsigned button);
virtual void DoMouseWheel(int x, int y, int d);
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void DoTextInput(String text);
// Sets halt and destroy, this causes the Windows to stop sending events and remove itself.
void SelfDestruct();
@ -102,8 +103,9 @@ namespace ui
virtual void OnMouseDown(int x, int y, unsigned button) {}
virtual void OnMouseUp(int x, int y, unsigned button) {}
virtual void OnMouseWheel(int x, int y, int d) {}
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {}
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) {}
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) {}
virtual void OnTextInput(String text) {}
std::vector<Component*> Components;
Component *focusedComponent_;
Component *hoverComponent;

View File

@ -114,21 +114,17 @@ void LocalBrowserView::textChanged()
else if (num > pageCount)
pageTextbox->SetText(String::Build(pageCount));
changed = true;
#ifdef USE_SDL
lastChanged = GetTicks()+600;
#endif
}
void LocalBrowserView::OnTick(float dt)
{
c->Update();
#ifdef USE_SDL
if (changed && lastChanged < GetTicks())
{
changed = false;
c->SetPage(std::max(pageTextbox->GetText().ToNumber<int>(true), 0));
}
#endif
}
void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender)
@ -266,16 +262,20 @@ void LocalBrowserView::OnMouseWheel(int x, int y, int d)
c->PrevPage();
}
void LocalBrowserView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void LocalBrowserView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (key == SDLK_ESCAPE)
c->Exit();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->SetMoveToFront(false);
}
void LocalBrowserView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void LocalBrowserView::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->SetMoveToFront(true);
}

View File

@ -38,8 +38,8 @@ public:
void NotifySavesListChanged(LocalBrowserModel * sender);
void NotifySelectedChanged(LocalBrowserModel * sender);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual ~LocalBrowserView();
};

View File

@ -73,8 +73,10 @@ LoginView::LoginView():
passwordField->SetHidden(true);
}
void LoginView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void LoginView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
switch(key)
{
case SDLK_TAB:

View File

@ -27,7 +27,7 @@ public:
class LoginAction;
class CancelAction;
LoginView();
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnTryExit(ExitMethod method);
void AttachController(LoginController * c_) { c = c_; }
void NotifyStatusChanged(LoginModel * sender);

View File

@ -8,7 +8,6 @@ OptionsController::OptionsController(GameModel * gModel_, ControllerCallback * c
callback(callback_),
HasExited(false)
{
this->depth3d = ui::Engine::Ref().Get3dDepth();
view = new OptionsView();
model = new OptionsModel(gModel);
model->AddObserver(view);
@ -56,6 +55,11 @@ void OptionsController::SetFullscreen(bool fullscreen)
model->SetFullscreen(fullscreen);
}
void OptionsController::SetAltFullscreen(bool altFullscreen)
{
model->SetAltFullscreen(altFullscreen);
}
void OptionsController::SetShowAvatars(bool showAvatars)
{
model->SetShowAvatars(showAvatars);
@ -66,16 +70,16 @@ void OptionsController::SetScale(int scale)
model->SetScale(scale);
}
void OptionsController::SetResizable(bool resizable)
{
model->SetResizable(resizable);
}
void OptionsController::SetFastQuit(bool fastquit)
{
model->SetFastQuit(fastquit);
}
void OptionsController::Set3dDepth(int depth)
{
depth3d = depth;
}
OptionsView * OptionsController::GetView()
{
return view;
@ -84,8 +88,6 @@ OptionsView * OptionsController::GetView()
void OptionsController::Exit()
{
view->CloseActiveWindow();
// only update on close, it would be hard to edit if the changes were live
ui::Engine::Ref().Set3dDepth(depth3d);
if (callback)
callback->ControllerExit();

View File

@ -14,7 +14,6 @@ class OptionsController {
OptionsView * view;
OptionsModel * model;
ControllerCallback * callback;
int depth3d;
public:
bool HasExited;
OptionsController(GameModel * gModel_, ControllerCallback * callback_);
@ -26,10 +25,11 @@ public:
void SetAirMode(int airMode);
void SetEdgeMode(int edgeMode);
void SetFullscreen(bool fullscreen);
void SetAltFullscreen(bool altFullscreen);
void SetScale(int scale);
void SetResizable(bool resizable);
void SetFastQuit(bool fastquit);
void SetShowAvatars(bool showAvatars);
void Set3dDepth(int depth);
void Exit();
OptionsView * GetView();
virtual ~OptionsController();

View File

@ -102,6 +102,18 @@ void OptionsModel::SetScale(int scale)
notifySettingsChanged();
}
bool OptionsModel::GetResizable()
{
return ui::Engine::Ref().GetResizable();
}
void OptionsModel::SetResizable(bool resizable)
{
ui::Engine::Ref().SetResizable(resizable);
Client::Ref().SetPref("Resizable", resizable);
notifySettingsChanged();
}
bool OptionsModel::GetFullscreen()
{
return ui::Engine::Ref().GetFullscreen();
@ -109,7 +121,19 @@ bool OptionsModel::GetFullscreen()
void OptionsModel::SetFullscreen(bool fullscreen)
{
ui::Engine::Ref().SetFullscreen(fullscreen);
Client::Ref().SetPref("Fullscreen", bool(fullscreen));
Client::Ref().SetPref("Fullscreen", fullscreen);
notifySettingsChanged();
}
bool OptionsModel::GetAltFullscreen()
{
return ui::Engine::Ref().GetAltFullscreen();
}
void OptionsModel::SetAltFullscreen(bool altFullscreen)
{
ui::Engine::Ref().SetAltFullscreen(altFullscreen);
Client::Ref().SetPref("AltFullscreen", altFullscreen);
notifySettingsChanged();
}

View File

@ -33,8 +33,12 @@ public:
void SetGravityMode(int gravityMode);
int GetScale();
void SetScale(int scale);
bool GetResizable();
void SetResizable(bool resizable);
bool GetFullscreen();
void SetFullscreen(bool fullscreen);
bool GetAltFullscreen();
void SetAltFullscreen(bool oldFullscreen);
bool GetFastQuit();
void SetFastQuit(bool fastquit);
virtual ~OptionsModel();

View File

@ -17,7 +17,7 @@
#include "gui/dialogues/ErrorMessage.h"
OptionsView::OptionsView():
ui::Window(ui::Point(-1, -1), ui::Point(300, 348)){
ui::Window(ui::Point(-1, -1), ui::Point(300, 369)){
ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
tempLabel->SetTextColour(style::Colour::InformationTitle);
@ -173,6 +173,24 @@ OptionsView::OptionsView():
AddComponent(tempLabel);
class ResizableAction: public ui::CheckboxAction
{
OptionsView * v;
public:
ResizableAction(OptionsView * v_){ v = v_; }
virtual void ActionCallback(ui::Checkbox * sender)
{
v->c->SetResizable(sender->GetChecked());
}
};
resizable = new ui::Checkbox(ui::Point(8, scale->Position.Y + 20), ui::Point(Size.X-6, 16), "Resizable", "");
resizable->SetActionCallback(new ResizableAction(this));
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText().c_str())+20, resizable->Position.Y), ui::Point(Size.X-28, 16), "\bg- Allow resizing and maximizing window");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempLabel);
AddComponent(resizable);
class FullscreenAction: public ui::CheckboxAction
{
OptionsView * v;
@ -180,23 +198,35 @@ OptionsView::OptionsView():
FullscreenAction(OptionsView * v_){ v = v_; }
virtual void ActionCallback(ui::Checkbox * sender)
{
#ifdef USE_SDL
#if defined(MACOSX) && !SDL_VERSION_ATLEAST(1, 2, 15)
ErrorMessage::Blocking("Information", "Fullscreen doesn't work on OS X");
#else
v->c->SetFullscreen(sender->GetChecked());
#endif
#endif
}
};
fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", "");
fullscreen = new ui::Checkbox(ui::Point(8, resizable->Position.Y + 20), ui::Point(Size.X-6, 16), "Fullscreen", "");
fullscreen->SetActionCallback(new FullscreenAction(this));
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText().c_str())+20, fullscreen->Position.Y), ui::Point(Size.X-28, 16), "\bg- Fill the entire screen");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempLabel);
AddComponent(fullscreen);
class AltFullscreenAction: public ui::CheckboxAction
{
OptionsView * v;
public:
AltFullscreenAction(OptionsView * v_){ v = v_; }
virtual void ActionCallback(ui::Checkbox * sender)
{
v->c->SetAltFullscreen(sender->GetChecked());
}
};
altFullscreen = new ui::Checkbox(ui::Point(23, fullscreen->Position.Y + 20), ui::Point(Size.X-6, 16), "Change Resolution", "");
altFullscreen->SetActionCallback(new AltFullscreenAction(this));
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText().c_str())+20, altFullscreen->Position.Y), ui::Point(Size.X-28, 16), "\bg- Set optimial screen resolution");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempLabel);
AddComponent(altFullscreen);
class FastQuitAction: public ui::CheckboxAction
{
@ -206,7 +236,7 @@ OptionsView::OptionsView():
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetFastQuit(sender->GetChecked()); }
};
fastquit = new ui::Checkbox(ui::Point(8, 250), ui::Point(Size.X-6, 16), "Fast Quit", "");
fastquit = new ui::Checkbox(ui::Point(8, altFullscreen->Position.Y + 20), ui::Point(Size.X-6, 16), "Fast Quit", "");
fastquit->SetActionCallback(new FastQuitAction(this));
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText().c_str())+20, fastquit->Position.Y), ui::Point(Size.X-28, 16), "\bg- Always exit completely when hitting close");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -221,29 +251,13 @@ OptionsView::OptionsView():
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetShowAvatars(sender->GetChecked()); }
};
showAvatars = new ui::Checkbox(ui::Point(8, 270), ui::Point(Size.X-6, 16), "Show Avatars", "");
showAvatars = new ui::Checkbox(ui::Point(8, fastquit->Position.Y + 20), ui::Point(Size.X-6, 16), "Show Avatars", "");
showAvatars->SetActionCallback(new ShowAvatarsAction(this));
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText().c_str())+20, showAvatars->Position.Y), ui::Point(Size.X-28, 16), "\bg- Disable if you have a slow connection");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempLabel);
AddComponent(showAvatars);
class DepthAction: public ui::TextboxAction
{
OptionsView * v;
public:
DepthAction(OptionsView * v_) { v = v_; }
virtual void TextChangedCallback(ui::Textbox * sender) { v->c->Set3dDepth(sender->GetText().ToNumber<int>(true)); }
};
depthTextbox = new ui::Textbox(ui::Point(8, Size.Y-58), ui::Point(25, 16), String::Build(ui::Engine::Ref().Get3dDepth()));
depthTextbox->SetInputType(ui::Textbox::Numeric);
depthTextbox->SetActionCallback(new DepthAction(this));
AddComponent(depthTextbox);
tempLabel = new ui::Label(ui::Point(depthTextbox->Position.X+depthTextbox->Size.X+3, depthTextbox->Position.Y), ui::Point(Size.X-28, 16), "\bg- Change the depth of the 3D anaglyph effect");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempLabel);
class DataFolderAction: public ui::ButtonAction
{
public:
@ -301,7 +315,9 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
gravityMode->SetOption(sender->GetGravityMode());
edgeMode->SetOption(sender->GetEdgeMode());
scale->SetOption(sender->GetScale());
resizable->SetChecked(sender->GetResizable());
fullscreen->SetChecked(sender->GetFullscreen());
altFullscreen->SetChecked(sender->GetAltFullscreen());
fastquit->SetChecked(sender->GetFastQuit());
showAvatars->SetChecked(sender->GetShowAvatars());
}

View File

@ -20,10 +20,11 @@ class OptionsView: public ui::Window {
ui::DropDown * gravityMode;
ui::DropDown * edgeMode;
ui::DropDown * scale;
ui::Checkbox * resizable;
ui::Checkbox * fullscreen;
ui::Checkbox * altFullscreen;
ui::Checkbox * fastquit;
ui::Checkbox * showAvatars;
ui::Textbox * depthTextbox;
public:
OptionsView();
void NotifySettingsChanged(OptionsModel * sender);

View File

@ -479,8 +479,10 @@ void PreviewView::OnMouseUp(int x, int y, unsigned int button)
}
}
void PreviewView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void PreviewView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if ((key == SDLK_KP_ENTER || key == SDLK_RETURN) && (!addCommentBox || !addCommentBox->IsFocused()))
openButton->DoAction();
}

View File

@ -85,7 +85,7 @@ public:
virtual void OnTryExit(ExitMethod method);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnMouseUp(int x, int y, unsigned int button);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual ~PreviewView();
};

View File

@ -405,8 +405,10 @@ void RenderView::OnTick(float dt)
}
}
void RenderView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void RenderView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (shift && key == '1')
c->LoadRenderPreset(10);
else if(key >= '0' && key <= '9')

View File

@ -37,7 +37,7 @@ public:
void OnTryExit(ExitMethod method);
virtual void OnDraw();
virtual void OnTick(float dt);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void ToolTip(ui::Point senderPosition, String toolTip);
virtual ~RenderView();
};

View File

@ -291,9 +291,7 @@ void SearchView::textChanged()
else if (num > pageCount)
pageTextbox->SetText(String::Build(pageCount));
changed = true;
#ifdef USE_SDL
lastChanged = GetTicks()+600;
#endif
}
void SearchView::OnTryOkay(OkayMethod method)
@ -780,13 +778,11 @@ void SearchView::NotifySelectedChanged(SearchModel * sender)
void SearchView::OnTick(float dt)
{
c->Update();
#ifdef USE_SDL
if (changed && lastChanged < GetTicks())
{
changed = false;
c->SetPage(std::max(pageTextbox->GetText().ToNumber<int>(true), 0));
}
#endif
}
void SearchView::OnMouseWheel(int x, int y, int d)
@ -798,16 +794,20 @@ void SearchView::OnMouseWheel(int x, int y, int d)
else
c->PrevPage();
}
void SearchView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (key == SDLK_ESCAPE)
c->Exit();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->InstantOpen(true);
}
void SearchView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void SearchView::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->InstantOpen(false);
}

View File

@ -69,8 +69,8 @@ public:
virtual void Search(String);
virtual void OnTick(float dt);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
};

View File

@ -131,8 +131,10 @@ void TagsView::NotifyTagsChanged(TagsModel * sender)
}
}
void TagsView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void TagsView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if (repeat)
return;
switch(key)
{
case SDLK_KP_ENTER:

View File

@ -25,7 +25,7 @@ public:
TagsView();
virtual void OnDraw();
void AttachController(TagsController * c_) { c = c_; }
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void NotifyTagsChanged(TagsModel * sender);
virtual ~TagsView();
};

View File

@ -25,8 +25,8 @@ public:
virtual bool OnMouseDown(int x, int y, unsigned button) {return true;}
virtual bool OnMouseUp(int x, int y, unsigned button, char type) {return true;}
virtual bool OnMouseWheel(int x, int y, int d) {return true;}
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
virtual bool OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) {return true;}
virtual bool OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) {return true;}
virtual bool OnMouseTick() { return true; }
virtual void OnTick() { }
virtual int Command(String command);

View File

@ -244,7 +244,7 @@ int luacon_elementwrite(lua_State* l)
}
bool shortcuts = true;
int luacon_keyevent(int key, Uint16 character, int modifier, int event)
int luacon_keyevent(int key, int scan, int modifier, int event)
{
ui::Engine::Ref().LastTick(Platform::GetTime());
int kycontinue = 1;
@ -263,10 +263,10 @@ int luacon_keyevent(int key, Uint16 character, int modifier, int event)
for (int i = 1; i <= len && kycontinue; i++)
{
lua_rawgeti(l, -1, i);
if ((modifier & KMOD_CTRL) && (character < ' ' || character > '~') && key < 256)
if ((modifier & KMOD_CTRL) && (scan < ' ' || scan > '~') && key < 256)
lua_pushlstring(l, (const char*)&key, 1);
else
lua_pushlstring(l, (const char*)&character, 1);
lua_pushlstring(l, (const char*)&scan, 1);
lua_pushinteger(l, key);
lua_pushinteger(l, modifier);
lua_pushinteger(l, event);

View File

@ -23,7 +23,7 @@ extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPart
void luacon_hook(lua_State *L, lua_Debug *ar);
int luacon_step(int mx, int my);
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
int luacon_keyevent(int key, Uint16 character, int modifier, int event);
int luacon_keyevent(int key, int scan, int modifier, int event);
int luacon_eval(const char *command);
String luacon_geterror();
void luacon_close();

View File

@ -2288,17 +2288,7 @@ int LuaScriptInterface::renderer_debugHUD(lua_State * l)
int LuaScriptInterface::renderer_depth3d(lua_State * l)
{
int acount = lua_gettop(l);
if (acount == 0)
{
lua_pushnumber(l, ui::Engine::Ref().Get3dDepth());
return 1;
}
int depth3d = luaL_optint(l, 1, -3);
if (depth3d < -30 || depth3d > 30)
return luaL_error(l, "3D depth is too large");
ui::Engine::Ref().Set3dDepth(depth3d);
return 0;
return luaL_error(l, "This feature is no longer supported");
}
void LuaScriptInterface::initElementsAPI()
@ -3374,12 +3364,12 @@ bool LuaScriptInterface::OnMouseWheel(int x, int y, int d)
return luacon_mouseevent(x, y, luacon_mousedown?luacon_mousebutton:0, 0, d);
}
bool LuaScriptInterface::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
bool LuaScriptInterface::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
return luacon_keyevent(key, character, GetModifiers(), LUACON_KDOWN);
return luacon_keyevent(key, scan, GetModifiers(), LUACON_KDOWN);
}
bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
bool LuaScriptInterface::OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
int modifiers = 0;
if(shift)

View File

@ -182,8 +182,8 @@ public:
virtual bool OnMouseDown(int x, int y, unsigned button);
virtual bool OnMouseUp(int x, int y, unsigned button, char type);
virtual bool OnMouseWheel(int x, int y, int d);
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual bool OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual bool OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
virtual bool OnMouseTick();
virtual void OnTick();
virtual void Init();

View File

@ -98,8 +98,8 @@ LuaWindow::LuaWindow(lua_State * l) :
virtual void OnMouseDown(int x, int y, unsigned button) { luaWindow->triggerOnMouseDown(x, y, button); }
virtual void OnMouseUp(int x, int y, unsigned button) { luaWindow->triggerOnMouseUp(x, y, button); }
virtual void OnMouseWheel(int x, int y, int d) { luaWindow->triggerOnMouseWheel(x, y, d); }
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { luaWindow->triggerOnKeyPress(key, character, shift, ctrl, alt); }
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { luaWindow->triggerOnKeyRelease(key, character, shift, ctrl, alt); }
virtual void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { luaWindow->triggerOnKeyPress(key, scan, repeat, shift, ctrl, alt); }
virtual void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) { luaWindow->triggerOnKeyRelease(key, scan, repeat, shift, ctrl, alt); }
};
window = new DrawnWindow(ui::Point(posX, posY), ui::Point(sizeX, sizeY), this);
@ -359,13 +359,13 @@ void LuaWindow::triggerOnMouseWheel(int x, int y, int d)
}
}
void LuaWindow::triggerOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void LuaWindow::triggerOnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(onKeyPressFunction)
{
lua_rawgeti(l, LUA_REGISTRYINDEX, onKeyPressFunction);
lua_pushinteger(l, key);
lua_pushinteger(l, character);
lua_pushinteger(l, scan);
lua_pushboolean(l, shift);
lua_pushboolean(l, ctrl);
lua_pushboolean(l, alt);
@ -376,13 +376,13 @@ void LuaWindow::triggerOnKeyPress(int key, Uint16 character, bool shift, bool ct
}
}
void LuaWindow::triggerOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void LuaWindow::triggerOnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if(onKeyReleaseFunction)
{
lua_rawgeti(l, LUA_REGISTRYINDEX, onKeyReleaseFunction);
lua_pushinteger(l, key);
lua_pushinteger(l, character);
lua_pushinteger(l, scan);
lua_pushboolean(l, shift);
lua_pushboolean(l, ctrl);
lua_pushboolean(l, alt);

View File

@ -60,8 +60,8 @@ class LuaWindow
void triggerOnMouseDown(int x, int y, unsigned button);
void triggerOnMouseUp(int x, int y, unsigned button);
void triggerOnMouseWheel(int x, int y, int d);
void triggerOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void triggerOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void triggerOnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
void triggerOnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt);
public:
LuaScriptInterface * ci;