mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-16 13:24:02 +02:00
Console UI, open in browser button, tab and enter shortcut for Login UI, various
This commit is contained in:
@@ -57,6 +57,8 @@
|
|||||||
#define BARSIZE 0
|
#define BARSIZE 0
|
||||||
#else
|
#else
|
||||||
#define MENUSIZE 40
|
#define MENUSIZE 40
|
||||||
|
//#define MENUSIZE 20
|
||||||
|
//#define BARSIZE 50
|
||||||
#define BARSIZE 17
|
#define BARSIZE 17
|
||||||
#endif
|
#endif
|
||||||
#define XRES 612
|
#define XRES 612
|
||||||
|
@@ -993,6 +993,11 @@ int Graphics::textnwidth(char *s, int n)
|
|||||||
{
|
{
|
||||||
if (!n)
|
if (!n)
|
||||||
break;
|
break;
|
||||||
|
if(((char)*s)=='\b')
|
||||||
|
{
|
||||||
|
s++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
@@ -1035,6 +1040,11 @@ int Graphics::textwidthx(char *s, int w)
|
|||||||
int x=0,n=0,cw;
|
int x=0,n=0,cw;
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
|
if((char)*s == '\b')
|
||||||
|
{
|
||||||
|
s++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
|
||||||
if (x+(cw/2) >= w)
|
if (x+(cw/2) >= w)
|
||||||
break;
|
break;
|
||||||
|
23
src/Misc.cpp
23
src/Misc.cpp
@@ -621,6 +621,29 @@ void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b)//convert 0-255(0-360 for
|
|||||||
*b += m;
|
*b += m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenURI(std::string uri) {
|
||||||
|
#ifdef WIN32
|
||||||
|
ShellExecute(0, "OPEN", uri.c_str(), NULL, NULL, 0);
|
||||||
|
#elif MACOSX
|
||||||
|
char *cmd = malloc(7+uri.length());
|
||||||
|
strcpy(cmd, "open ");
|
||||||
|
strappend(cmd, uri.c_str());
|
||||||
|
system(cmd);
|
||||||
|
#elif LIN32
|
||||||
|
char *cmd = malloc(11+uri.length());
|
||||||
|
strcpy(cmd, "xdg-open ");
|
||||||
|
strappend(cmd, uri.c_str());
|
||||||
|
system(cmd);
|
||||||
|
#elif LIN64
|
||||||
|
char *cmd = malloc(11+uri.length());
|
||||||
|
strcpy(cmd, "xdg-open ");
|
||||||
|
strappend(cmd, uri.c_str());
|
||||||
|
system(cmd);
|
||||||
|
#else
|
||||||
|
printf("Cannot open browser\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v)//convert 0-255 RGB values to 0-255(0-360 for H) HSV
|
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v)//convert 0-255 RGB values to 0-255(0-360 for H) HSV
|
||||||
{
|
{
|
||||||
float rr, gg, bb, a,x,c,d;
|
float rr, gg, bb, a,x,c,d;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
enum HorizontalAlignment
|
enum HorizontalAlignment
|
||||||
{
|
{
|
||||||
@@ -86,6 +87,8 @@ void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b);
|
|||||||
|
|
||||||
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v);
|
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v);
|
||||||
|
|
||||||
|
void OpenURI(std::string uri);
|
||||||
|
|
||||||
void membwand(void * dest, void * src, size_t destsize, size_t srcsize);
|
void membwand(void * dest, void * src, size_t destsize, size_t srcsize);
|
||||||
// a b
|
// a b
|
||||||
// c d
|
// c d
|
||||||
|
25
src/console/ConsoleCommand.h
Normal file
25
src/console/ConsoleCommand.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleCommand.h
|
||||||
|
*
|
||||||
|
* Created on: Feb 1, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONSOLECOMMAND_H_
|
||||||
|
#define CONSOLECOMMAND_H_
|
||||||
|
|
||||||
|
class ConsoleCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConsoleCommand(std::string command, int returnStatus, std::string returnValue):
|
||||||
|
Command(command), ReturnStatus(returnStatus), ReturnValue(returnValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
std::string Command;
|
||||||
|
int ReturnStatus;
|
||||||
|
std::string ReturnValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONSOLECOMMAND_H_ */
|
102
src/console/ConsoleController.cpp
Normal file
102
src/console/ConsoleController.cpp
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleController.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 31, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
|
#include "ConsoleController.h"
|
||||||
|
|
||||||
|
ConsoleController::ConsoleController(ControllerCallback * callback):
|
||||||
|
HasDone(false)
|
||||||
|
{
|
||||||
|
consoleModel = new ConsoleModel();
|
||||||
|
consoleView = new ConsoleView();
|
||||||
|
consoleView->AttachController(this);
|
||||||
|
consoleModel->AddObserver(consoleView);
|
||||||
|
|
||||||
|
this->callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleController::EvaluateCommand(std::string command)
|
||||||
|
{
|
||||||
|
if(command.length())
|
||||||
|
consoleModel->AddLastCommand(ConsoleCommand(command, -1, "Syntax error"));
|
||||||
|
else
|
||||||
|
if(ui::Engine::Ref().GetWindow() == consoleView)
|
||||||
|
ui::Engine::Ref().CloseWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ConsoleController::FormatCommand(std::string command)
|
||||||
|
{
|
||||||
|
char * rawText = (char*)command.c_str();
|
||||||
|
char * outputData = (char *)calloc(command.length()*6, 1);
|
||||||
|
int rawTextLoc = 0;
|
||||||
|
int outputDataLoc = 0;
|
||||||
|
std::stack<char> pstack;
|
||||||
|
while(rawText[rawTextLoc])
|
||||||
|
{
|
||||||
|
switch(rawText[rawTextLoc])
|
||||||
|
{
|
||||||
|
case '\\':
|
||||||
|
outputData[outputDataLoc++] = rawText[rawTextLoc++];
|
||||||
|
if(rawText[rawTextLoc])
|
||||||
|
outputData[outputDataLoc++] = rawText[rawTextLoc++];
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
if(pstack.size() && pstack.top() == '"')
|
||||||
|
{
|
||||||
|
pstack.pop();
|
||||||
|
outputData[outputDataLoc++] = rawText[rawTextLoc++];
|
||||||
|
outputData[outputDataLoc++] = '\b';
|
||||||
|
outputData[outputDataLoc++] = 'w';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pstack.push('"');
|
||||||
|
outputData[outputDataLoc++] = '\b';
|
||||||
|
outputData[outputDataLoc++] = 'o';
|
||||||
|
outputData[outputDataLoc++] = rawText[rawTextLoc++];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outputData[outputDataLoc++] = rawText[rawTextLoc++];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleController::NextCommand()
|
||||||
|
{
|
||||||
|
int cIndex = consoleModel->GetCurrentCommandIndex();
|
||||||
|
if(cIndex < consoleModel->GetPreviousCommands().size())
|
||||||
|
consoleModel->SetCurrentCommandIndex(cIndex+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleController::PreviousCommand()
|
||||||
|
{
|
||||||
|
int cIndex = consoleModel->GetCurrentCommandIndex();
|
||||||
|
if(cIndex > 0)
|
||||||
|
consoleModel->SetCurrentCommandIndex(cIndex-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleController::Exit()
|
||||||
|
{
|
||||||
|
if(ui::Engine::Ref().GetWindow() == consoleView)
|
||||||
|
ui::Engine::Ref().CloseWindow();
|
||||||
|
if(callback)
|
||||||
|
callback->ControllerExit();
|
||||||
|
HasDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleView * ConsoleController::GetView()
|
||||||
|
{
|
||||||
|
return consoleView;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleController::~ConsoleController() {
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
35
src/console/ConsoleController.h
Normal file
35
src/console/ConsoleController.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleController.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 31, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONSOLECONTROLLER_H_
|
||||||
|
#define CONSOLECONTROLLER_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "Controller.h"
|
||||||
|
#include "ConsoleView.h"
|
||||||
|
#include "ConsoleModel.h"
|
||||||
|
#include "ConsoleCommand.h"
|
||||||
|
|
||||||
|
class ConsoleModel;
|
||||||
|
class ConsoleView;
|
||||||
|
class ConsoleController {
|
||||||
|
ControllerCallback * callback;
|
||||||
|
ConsoleView * consoleView;
|
||||||
|
ConsoleModel * consoleModel;
|
||||||
|
public:
|
||||||
|
bool HasDone;
|
||||||
|
ConsoleController(ControllerCallback * callback);
|
||||||
|
std::string FormatCommand(std::string command);
|
||||||
|
void EvaluateCommand(std::string command);
|
||||||
|
void NextCommand();
|
||||||
|
void PreviousCommand();
|
||||||
|
void Exit();
|
||||||
|
ConsoleView * GetView();
|
||||||
|
virtual ~ConsoleController();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CONSOLECONTROLLER_H_ */
|
72
src/console/ConsoleModel.cpp
Normal file
72
src/console/ConsoleModel.cpp
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleModel.cpp
|
||||||
|
*
|
||||||
|
* Created on: Feb 1, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ConsoleModel.h"
|
||||||
|
|
||||||
|
ConsoleModel::ConsoleModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleModel::AddObserver(ConsoleView * observer)
|
||||||
|
{
|
||||||
|
observers.push_back(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ConsoleModel::GetCurrentCommandIndex()
|
||||||
|
{
|
||||||
|
return currentCommandIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleModel::SetCurrentCommandIndex(int index)
|
||||||
|
{
|
||||||
|
currentCommandIndex = index;
|
||||||
|
notifyCurrentCommandChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleCommand ConsoleModel::GetCurrentCommand()
|
||||||
|
{
|
||||||
|
if(currentCommandIndex < 0 || currentCommandIndex >= previousCommands.size())
|
||||||
|
{
|
||||||
|
return ConsoleCommand("", 0, "");
|
||||||
|
}
|
||||||
|
return previousCommands[currentCommandIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleModel::AddLastCommand(ConsoleCommand command)
|
||||||
|
{
|
||||||
|
previousCommands.push_back(command);
|
||||||
|
if(previousCommands.size()>25)
|
||||||
|
previousCommands.pop_front();
|
||||||
|
currentCommandIndex = previousCommands.size();
|
||||||
|
notifyPreviousCommandsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::deque<ConsoleCommand> ConsoleModel::GetPreviousCommands()
|
||||||
|
{
|
||||||
|
return previousCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleModel::notifyPreviousCommandsChanged()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < observers.size(); i++)
|
||||||
|
{
|
||||||
|
observers[i]->NotifyPreviousCommandsChanged(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleModel::notifyCurrentCommandChanged()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < observers.size(); i++)
|
||||||
|
{
|
||||||
|
observers[i]->NotifyCurrentCommandChanged(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleModel::~ConsoleModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
35
src/console/ConsoleModel.h
Normal file
35
src/console/ConsoleModel.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleModel.h
|
||||||
|
*
|
||||||
|
* Created on: Feb 1, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONSOLEMODEL_H_
|
||||||
|
#define CONSOLEMODEL_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
|
#include "ConsoleView.h"
|
||||||
|
#include "ConsoleCommand.h"
|
||||||
|
|
||||||
|
class ConsoleView;
|
||||||
|
class ConsoleModel {
|
||||||
|
int currentCommandIndex;
|
||||||
|
std::vector<ConsoleView*> observers;
|
||||||
|
std::deque<ConsoleCommand> previousCommands;
|
||||||
|
void notifyPreviousCommandsChanged();
|
||||||
|
void notifyCurrentCommandChanged();
|
||||||
|
public:
|
||||||
|
int GetCurrentCommandIndex();
|
||||||
|
void SetCurrentCommandIndex(int index);
|
||||||
|
ConsoleCommand GetCurrentCommand();
|
||||||
|
|
||||||
|
std::deque<ConsoleCommand> GetPreviousCommands();
|
||||||
|
ConsoleModel();
|
||||||
|
void AddObserver(ConsoleView * observer);
|
||||||
|
void AddLastCommand(ConsoleCommand command);
|
||||||
|
virtual ~ConsoleModel();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CONSOLEMODEL_H_ */
|
90
src/console/ConsoleView.cpp
Normal file
90
src/console/ConsoleView.cpp
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleView.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 31, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ConsoleView.h"
|
||||||
|
#include "interface/Keys.h"
|
||||||
|
|
||||||
|
ConsoleView::ConsoleView():
|
||||||
|
ui::Window(ui::Point(0, 0), ui::Point(XRES+BARSIZE, 150)),
|
||||||
|
commandField(NULL)
|
||||||
|
{
|
||||||
|
class CommandHighlighter: public ui::TextboxAction
|
||||||
|
{
|
||||||
|
ConsoleView * v;
|
||||||
|
public:
|
||||||
|
CommandHighlighter(ConsoleView * v_) { v = v_; }
|
||||||
|
void TextChangedCallback(ui::Textbox * sender)
|
||||||
|
{
|
||||||
|
sender->SetDisplayText(v->c->FormatCommand(sender->GetText()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "");
|
||||||
|
commandField->SetAlignment(AlignLeft, AlignBottom);
|
||||||
|
commandField->SetActionCallback(new CommandHighlighter(this));
|
||||||
|
AddComponent(commandField);
|
||||||
|
FocusComponent(commandField);
|
||||||
|
commandField->SetBorder(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case KEY_RETURN:
|
||||||
|
case KEY_ENTER:
|
||||||
|
c->EvaluateCommand(commandField->GetText());
|
||||||
|
commandField->SetText("");
|
||||||
|
break;
|
||||||
|
case KEY_DOWN:
|
||||||
|
c->NextCommand();
|
||||||
|
break;
|
||||||
|
case KEY_UP:
|
||||||
|
c->PreviousCommand();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleView::NotifyPreviousCommandsChanged(ConsoleModel * sender)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < commandList.size(); i++)
|
||||||
|
{
|
||||||
|
RemoveComponent(commandList[i]);
|
||||||
|
delete commandList[i];
|
||||||
|
}
|
||||||
|
commandList.clear();
|
||||||
|
std::deque<ConsoleCommand> commands = sender->GetPreviousCommands();
|
||||||
|
int currentY = Size.Y - 32;
|
||||||
|
if(commands.size())
|
||||||
|
for(int i = commands.size()-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if(currentY <= 0)
|
||||||
|
break;
|
||||||
|
ui::Label * tempLabel = new ui::Label(ui::Point(0, currentY), ui::Point(Size.X, 16), commands[i].Command);
|
||||||
|
tempLabel->SetAlignment(AlignLeft, AlignMiddle);
|
||||||
|
commandList.push_back(tempLabel);
|
||||||
|
AddComponent(tempLabel);
|
||||||
|
currentY-=16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender)
|
||||||
|
{
|
||||||
|
commandField->SetText(sender->GetCurrentCommand().Command);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConsoleView::OnDraw()
|
||||||
|
{
|
||||||
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
|
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 0, 0, 0, 110);
|
||||||
|
g->blend_line(Position.X, Position.Y+Size.Y-16, Position.X+Size.X, Position.Y+Size.Y-16, 255, 255, 255, 160);
|
||||||
|
g->blend_line(Position.X, Position.Y+Size.Y, Position.X+Size.X, Position.Y+Size.Y, 255, 255, 255, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleView::~ConsoleView() {
|
||||||
|
}
|
||||||
|
|
37
src/console/ConsoleView.h
Normal file
37
src/console/ConsoleView.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* ConsoleView.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 31, 2012
|
||||||
|
* Author: Simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONSOLEVIEW_H_
|
||||||
|
#define CONSOLEVIEW_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
#include "interface/Label.h"
|
||||||
|
#include "interface/Window.h"
|
||||||
|
#include "ConsoleController.h"
|
||||||
|
#include "ConsoleModel.h"
|
||||||
|
#include "interface/Textbox.h"
|
||||||
|
#include "ConsoleCommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ConsoleController;
|
||||||
|
class ConsoleModel;
|
||||||
|
class ConsoleView: public ui::Window {
|
||||||
|
ConsoleController * c;
|
||||||
|
ui::Textbox * commandField;
|
||||||
|
std::vector<ui::Label*> commandList;
|
||||||
|
public:
|
||||||
|
ConsoleView();
|
||||||
|
virtual void OnDraw();
|
||||||
|
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
|
void AttachController(ConsoleController * c_) { c = c_; }
|
||||||
|
void NotifyPreviousCommandsChanged(ConsoleModel * sender);
|
||||||
|
void NotifyCurrentCommandChanged(ConsoleModel * sender);
|
||||||
|
virtual ~ConsoleView();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CONSOLEVIEW_H_ */
|
@@ -95,6 +95,10 @@ GameController::~GameController()
|
|||||||
{
|
{
|
||||||
delete loginWindow;
|
delete loginWindow;
|
||||||
}
|
}
|
||||||
|
if(console)
|
||||||
|
{
|
||||||
|
delete console;
|
||||||
|
}
|
||||||
if(ui::Engine::Ref().GetWindow() == gameView)
|
if(ui::Engine::Ref().GetWindow() == gameView)
|
||||||
{
|
{
|
||||||
ui::Engine::Ref().CloseWindow();
|
ui::Engine::Ref().CloseWindow();
|
||||||
@@ -301,6 +305,12 @@ void GameController::OpenDisplayOptions()
|
|||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::ShowConsole()
|
||||||
|
{
|
||||||
|
console = new ConsoleController(NULL);
|
||||||
|
ui::Engine::Ref().ShowWindow(console->GetView());
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::OpenRenderOptions()
|
void GameController::OpenRenderOptions()
|
||||||
{
|
{
|
||||||
renderOptions = new RenderController(gameModel->GetRenderer(), new RenderCallback(this));
|
renderOptions = new RenderController(gameModel->GetRenderer(), new RenderCallback(this));
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "render/RenderController.h"
|
#include "render/RenderController.h"
|
||||||
#include "login/LoginController.h"
|
#include "login/LoginController.h"
|
||||||
#include "ssave/SSaveController.h"
|
#include "ssave/SSaveController.h"
|
||||||
|
#include "console/ConsoleController.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -26,6 +27,7 @@ private:
|
|||||||
RenderController * renderOptions;
|
RenderController * renderOptions;
|
||||||
LoginController * loginWindow;
|
LoginController * loginWindow;
|
||||||
SSaveController * ssave;
|
SSaveController * ssave;
|
||||||
|
ConsoleController * console;
|
||||||
public:
|
public:
|
||||||
class LoginCallback;
|
class LoginCallback;
|
||||||
class SearchCallback;
|
class SearchCallback;
|
||||||
@@ -57,6 +59,7 @@ public:
|
|||||||
void ReloadSim();
|
void ReloadSim();
|
||||||
void Vote(int direction);
|
void Vote(int direction);
|
||||||
void ChangeBrush();
|
void ChangeBrush();
|
||||||
|
void ShowConsole();
|
||||||
ui::Point PointTranslate(ui::Point point);
|
ui::Point PointTranslate(ui::Point point);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -41,12 +41,19 @@ GameModel::GameModel():
|
|||||||
//sim->wtypes[i]
|
//sim->wtypes[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set default brush palette
|
||||||
brushList.push_back(new Brush(ui::Point(4, 4)));
|
brushList.push_back(new Brush(ui::Point(4, 4)));
|
||||||
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
|
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
|
||||||
|
|
||||||
activeTools[0] = new ElementTool(1, "TURD", 0, 0, 0);
|
//Set default tools
|
||||||
activeTools[1] = new ElementTool(0, "TURD", 0, 0, 0);
|
activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
|
||||||
//activeTool[1] = new ElementTool(0, "TURD", 0, 0, 0);
|
activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
|
||||||
|
|
||||||
|
//Set default menu
|
||||||
|
activeMenu = menuList[SC_POWDERS];
|
||||||
|
toolList = menuList[SC_POWDERS]->GetToolList();
|
||||||
|
|
||||||
|
//Load last user
|
||||||
std::cout << Client::Ref().GetAuthUser().Username << std::endl;
|
std::cout << Client::Ref().GetAuthUser().Username << std::endl;
|
||||||
if(Client::Ref().GetAuthUser().ID)
|
if(Client::Ref().GetAuthUser().ID)
|
||||||
{
|
{
|
||||||
|
@@ -277,6 +277,7 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
|||||||
|
|
||||||
void GameView::NotifyToolListChanged(GameModel * sender)
|
void GameView::NotifyToolListChanged(GameModel * sender)
|
||||||
{
|
{
|
||||||
|
//int currentY = YRES+MENUSIZE-36;
|
||||||
int currentX = XRES+BARSIZE-56;
|
int currentX = XRES+BARSIZE-56;
|
||||||
int totalColour;
|
int totalColour;
|
||||||
for(int i = 0; i < menuButtons.size(); i++)
|
for(int i = 0; i < menuButtons.size(); i++)
|
||||||
@@ -299,8 +300,10 @@ void GameView::NotifyToolListChanged(GameModel * sender)
|
|||||||
vector<Tool*> toolList = sender->GetToolList();
|
vector<Tool*> toolList = sender->GetToolList();
|
||||||
for(int i = 0; i < toolList.size(); i++)
|
for(int i = 0; i < toolList.size(); i++)
|
||||||
{
|
{
|
||||||
ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES), ui::Point(32, 16), toolList[i]->GetName());
|
//ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName());
|
||||||
currentX -= 36;
|
ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(28, 15), toolList[i]->GetName());
|
||||||
|
//currentY -= 17;
|
||||||
|
currentX -= 32;
|
||||||
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
|
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
|
||||||
|
|
||||||
tempButton->SetBackgroundColour(ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue));
|
tempButton->SetBackgroundColour(ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue));
|
||||||
@@ -507,6 +510,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
zoomCursorFixed = false;
|
zoomCursorFixed = false;
|
||||||
c->SetZoomEnabled(true);
|
c->SetZoomEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
case '`':
|
||||||
|
c->ShowConsole();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,11 +43,11 @@ void ToolButton::Draw(const ui::Point& screenPos)
|
|||||||
|
|
||||||
if (totalColour<544)
|
if (totalColour<544)
|
||||||
{
|
{
|
||||||
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, ButtonText.c_str(), 255, 255, 255, 255);
|
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText.c_str(), 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, ButtonText.c_str(), 0, 0, 0, 255);
|
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText.c_str(), 0, 0, 0, 255);
|
||||||
}
|
}
|
||||||
if(currentSelection!=-1)
|
if(currentSelection!=-1)
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,7 @@ Button::Button(Point position, Point size, std::string buttonText):
|
|||||||
actionCallback(NULL),
|
actionCallback(NULL),
|
||||||
textPosition(ui::Point(0, 0)),
|
textPosition(ui::Point(0, 0)),
|
||||||
textVAlign(AlignMiddle),
|
textVAlign(AlignMiddle),
|
||||||
textHAlign(AlignCentre),
|
textHAlign(AlignLeft),
|
||||||
Enabled(true),
|
Enabled(true),
|
||||||
icon(NoIcon)
|
icon(NoIcon)
|
||||||
{
|
{
|
||||||
@@ -36,6 +36,16 @@ Button::Button(Point position, Point size, std::string buttonText):
|
|||||||
|
|
||||||
void Button::TextPosition()
|
void Button::TextPosition()
|
||||||
{
|
{
|
||||||
|
buttonDisplayText = ButtonText;
|
||||||
|
if(buttonDisplayText.length())
|
||||||
|
{
|
||||||
|
if(Graphics::textwidth((char *)buttonDisplayText.c_str()) > Size.X - (icon? 22 : 0))
|
||||||
|
{
|
||||||
|
int position = Graphics::textwidthx((char *)buttonDisplayText.c_str(), Size.X - (icon? 38 : 22));
|
||||||
|
buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position);
|
||||||
|
buttonDisplayText += "...";
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(textVAlign)
|
switch(textVAlign)
|
||||||
{
|
{
|
||||||
case AlignTop:
|
case AlignTop:
|
||||||
@@ -45,7 +55,7 @@ void Button::TextPosition()
|
|||||||
textPosition.Y = (Size.Y-10)/2;
|
textPosition.Y = (Size.Y-10)/2;
|
||||||
break;
|
break;
|
||||||
case AlignBottom:
|
case AlignBottom:
|
||||||
textPosition.Y = Size.Y-11;
|
textPosition.Y = Size.Y-12;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +67,10 @@ void Button::TextPosition()
|
|||||||
textPosition.X = 3+17;
|
textPosition.X = 3+17;
|
||||||
break;
|
break;
|
||||||
case AlignCentre:
|
case AlignCentre:
|
||||||
textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)ButtonText.c_str()))/2)+17;
|
textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)buttonDisplayText.c_str()))/2)+17;
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)ButtonText.c_str()))-2)+17;
|
textPosition.X = (((Size.X-14)-Graphics::textwidth((char *)buttonDisplayText.c_str()))-2)+17;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,10 +82,10 @@ void Button::TextPosition()
|
|||||||
textPosition.X = 3;
|
textPosition.X = 3;
|
||||||
break;
|
break;
|
||||||
case AlignCentre:
|
case AlignCentre:
|
||||||
textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2;
|
textPosition.X = (Size.X-Graphics::textwidth((char *)buttonDisplayText.c_str()))/2;
|
||||||
break;
|
break;
|
||||||
case AlignRight:
|
case AlignRight:
|
||||||
textPosition.X = (Size.X-Graphics::textwidth((char *)ButtonText.c_str()))-2;
|
textPosition.X = (Size.X-Graphics::textwidth((char *)buttonDisplayText.c_str()))-2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,20 +134,20 @@ void Button::Draw(const Point& screenPos)
|
|||||||
{
|
{
|
||||||
g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255);
|
g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255);
|
||||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255);
|
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255);
|
||||||
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, ButtonText, activeText.Red, activeText.Green, activeText.Blue, 255);
|
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, activeText.Red, activeText.Green, activeText.Blue, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255);
|
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255);
|
||||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
|
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
|
||||||
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, ButtonText, text.Red, text.Green, text.Blue, 255);
|
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, text.Red, text.Green, text.Blue, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 180);
|
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 180);
|
||||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255);
|
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255);
|
||||||
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, ButtonText, 180, 180, 180, 255);
|
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, 180, 180, 180, 255);
|
||||||
}
|
}
|
||||||
if(icon)
|
if(icon)
|
||||||
g->draw_icon(Position.X+3, Position.Y+textPosition.Y, icon);
|
g->draw_icon(Position.X+3, Position.Y+textPosition.Y, icon);
|
||||||
|
@@ -33,8 +33,6 @@ public:
|
|||||||
bool Toggleable;
|
bool Toggleable;
|
||||||
bool Enabled;
|
bool Enabled;
|
||||||
|
|
||||||
std::string ButtonText;
|
|
||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseUp(int x, int y, unsigned int button);
|
virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
//virtual void OnMouseUp(int x, int y, unsigned int button);
|
//virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
@@ -72,6 +70,9 @@ protected:
|
|||||||
Colour border, activeBorder;
|
Colour border, activeBorder;
|
||||||
Colour text, activeText;
|
Colour text, activeText;
|
||||||
|
|
||||||
|
std::string buttonDisplayText;
|
||||||
|
std::string ButtonText;
|
||||||
|
|
||||||
bool isButtonDown, state, isMouseInside, isTogglable, toggle;
|
bool isButtonDown, state, isMouseInside, isTogglable, toggle;
|
||||||
ButtonAction * actionCallback;
|
ButtonAction * actionCallback;
|
||||||
ui::Point textPosition;
|
ui::Point textPosition;
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
#define KEY_BACKSPACE SDLK_BACKSPACE
|
#define KEY_BACKSPACE SDLK_BACKSPACE
|
||||||
#define KEY_DELETE SDLK_DELETE
|
#define KEY_DELETE SDLK_DELETE
|
||||||
#define KEY_TAB SDLK_TAB
|
#define KEY_TAB SDLK_TAB
|
||||||
|
#define KEY_RETURN SDLK_RETURN
|
||||||
|
#define KEY_ENTER SDLK_KP_ENTER
|
||||||
|
|
||||||
#define KEY_CTRL SDLK_LCTRL
|
#define KEY_CTRL SDLK_LCTRL
|
||||||
#define KEY_ALT SDLK_LALT
|
#define KEY_ALT SDLK_LALT
|
||||||
|
@@ -16,7 +16,8 @@ Textbox::Textbox(Point position, Point size, std::string textboxText):
|
|||||||
textVAlign(AlignMiddle),
|
textVAlign(AlignMiddle),
|
||||||
textHAlign(AlignCentre),
|
textHAlign(AlignCentre),
|
||||||
actionCallback(NULL),
|
actionCallback(NULL),
|
||||||
masked(false)
|
masked(false),
|
||||||
|
border(true)
|
||||||
{
|
{
|
||||||
SetText(textboxText);
|
SetText(textboxText);
|
||||||
TextPosition();
|
TextPosition();
|
||||||
@@ -31,11 +32,9 @@ Textbox::~Textbox()
|
|||||||
|
|
||||||
void Textbox::TextPosition()
|
void Textbox::TextPosition()
|
||||||
{
|
{
|
||||||
std::string tempText = displayText;
|
if(cursor)
|
||||||
if(tempText.length() && cursor)
|
|
||||||
{
|
{
|
||||||
tempText.erase(cursor, tempText.length()-cursor);
|
cursorPosition = Graphics::textnwidth((char *)displayText.c_str(), cursor);
|
||||||
cursorPosition = Graphics::textwidth((char *)tempText.c_str());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -71,6 +70,7 @@ void Textbox::TextPosition()
|
|||||||
|
|
||||||
void Textbox::SetText(std::string text)
|
void Textbox::SetText(std::string text)
|
||||||
{
|
{
|
||||||
|
cursor = text.length();
|
||||||
if(masked)
|
if(masked)
|
||||||
{
|
{
|
||||||
char tempText[text.length()];
|
char tempText[text.length()];
|
||||||
@@ -86,6 +86,13 @@ void Textbox::SetText(std::string text)
|
|||||||
TextPosition();
|
TextPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Textbox::SetDisplayText(std::string text)
|
||||||
|
{
|
||||||
|
displayText = text;
|
||||||
|
TextPosition();
|
||||||
|
}
|
||||||
|
|
||||||
std::string Textbox::GetText()
|
std::string Textbox::GetText()
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
@@ -153,17 +160,18 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
cursor++;
|
cursor++;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if(changed && actionCallback)
|
|
||||||
{
|
|
||||||
actionCallback->TextChangedCallback(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(std::out_of_range &e)
|
catch(std::out_of_range &e)
|
||||||
{
|
{
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
SetText(text);
|
if(changed)
|
||||||
|
{
|
||||||
|
SetText(text);
|
||||||
|
if(actionCallback)
|
||||||
|
actionCallback->TextChangedCallback(this);
|
||||||
|
}
|
||||||
TextPosition();
|
TextPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,12 +180,12 @@ void Textbox::Draw(const Point& screenPos)
|
|||||||
Graphics * g = Engine::Ref().g;
|
Graphics * g = Engine::Ref().g;
|
||||||
if(IsFocused())
|
if(IsFocused())
|
||||||
{
|
{
|
||||||
g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);
|
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, XRES+BARSIZE);
|
g->draw_line(screenPos.X+textPosition.X+cursorPosition, screenPos.Y+3, screenPos.X+textPosition.X+cursorPosition, screenPos.Y+12, 255, 255, 255, XRES+BARSIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
|
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);
|
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ public:
|
|||||||
};
|
};
|
||||||
class Textbox : public Component
|
class Textbox : public Component
|
||||||
{
|
{
|
||||||
|
friend class TextboxAction;
|
||||||
protected:
|
protected:
|
||||||
std::string text;
|
std::string text;
|
||||||
std::string displayText;
|
std::string displayText;
|
||||||
@@ -26,12 +27,14 @@ protected:
|
|||||||
int cursor, cursorPosition;
|
int cursor, cursorPosition;
|
||||||
TextboxAction *actionCallback;
|
TextboxAction *actionCallback;
|
||||||
bool masked;
|
bool masked;
|
||||||
|
bool border;
|
||||||
public:
|
public:
|
||||||
Textbox(Point position, Point size, std::string textboxText);
|
Textbox(Point position, Point size, std::string textboxText);
|
||||||
virtual ~Textbox();
|
virtual ~Textbox();
|
||||||
|
|
||||||
virtual void TextPosition();
|
virtual void TextPosition();
|
||||||
virtual void SetText(std::string text);
|
virtual void SetText(std::string text);
|
||||||
|
virtual void SetDisplayText(std::string text);
|
||||||
std::string GetText();
|
std::string GetText();
|
||||||
HorizontalAlignment GetHAlignment() { return textHAlign; }
|
HorizontalAlignment GetHAlignment() { return textHAlign; }
|
||||||
VerticalAlignment GetVAlignment() { return textVAlign; }
|
VerticalAlignment GetVAlignment() { return textVAlign; }
|
||||||
@@ -42,6 +45,8 @@ public:
|
|||||||
void SetHidden(bool hidden) { masked = hidden; }
|
void SetHidden(bool hidden) { masked = hidden; }
|
||||||
bool GetHidden() { return masked; }
|
bool GetHidden() { return masked; }
|
||||||
|
|
||||||
|
void SetBorder(bool border) {this->border = border;}
|
||||||
|
|
||||||
virtual void Draw(const Point& screenPos);
|
virtual void Draw(const Point& screenPos);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,24 @@ LoginView::LoginView():
|
|||||||
AddComponent(infoLabel);
|
AddComponent(infoLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoginView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case KEY_TAB:
|
||||||
|
if(IsFocused(usernameField))
|
||||||
|
FocusComponent(passwordField);
|
||||||
|
else
|
||||||
|
FocusComponent(usernameField);
|
||||||
|
break;
|
||||||
|
case KEY_ENTER:
|
||||||
|
case KEY_RETURN:
|
||||||
|
if(IsFocused(passwordField))
|
||||||
|
loginButton->DoAction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LoginView::NotifyStatusChanged(LoginModel * sender)
|
void LoginView::NotifyStatusChanged(LoginModel * sender)
|
||||||
{
|
{
|
||||||
infoLabel->SetText(sender->GetStatusText());
|
infoLabel->SetText(sender->GetStatusText());
|
||||||
|
@@ -29,6 +29,7 @@ public:
|
|||||||
class LoginAction;
|
class LoginAction;
|
||||||
class CancelAction;
|
class CancelAction;
|
||||||
LoginView();
|
LoginView();
|
||||||
|
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
void AttachController(LoginController * c_) { c = c_; }
|
void AttachController(LoginController * c_) { c = c_; }
|
||||||
void NotifyStatusChanged(LoginModel * sender);
|
void NotifyStatusChanged(LoginModel * sender);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
* Author: Simon
|
* Author: Simon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include "PreviewController.h"
|
#include "PreviewController.h"
|
||||||
#include "PreviewView.h"
|
#include "PreviewView.h"
|
||||||
#include "PreviewModel.h"
|
#include "PreviewModel.h"
|
||||||
@@ -43,6 +44,16 @@ void PreviewController::DoOpen()
|
|||||||
previewModel->SetDoOpen(true);
|
previewModel->SetDoOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewController::OpenInBrowser()
|
||||||
|
{
|
||||||
|
if(previewModel->GetSave())
|
||||||
|
{
|
||||||
|
std::stringstream uriStream;
|
||||||
|
uriStream << "http://" << SERVER << "/Browse/View.html?ID=" << previewModel->GetSave()->id;
|
||||||
|
OpenURI(uriStream.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewController::Exit()
|
void PreviewController::Exit()
|
||||||
{
|
{
|
||||||
if(ui::Engine::Ref().GetWindow() == previewView)
|
if(ui::Engine::Ref().GetWindow() == previewView)
|
||||||
|
@@ -24,6 +24,7 @@ public:
|
|||||||
PreviewController(int saveID, ControllerCallback * callback);
|
PreviewController(int saveID, ControllerCallback * callback);
|
||||||
void Exit();
|
void Exit();
|
||||||
void DoOpen();
|
void DoOpen();
|
||||||
|
void OpenInBrowser();
|
||||||
bool GetDoOpen();
|
bool GetDoOpen();
|
||||||
Save * GetSave();
|
Save * GetSave();
|
||||||
PreviewView * GetView() { return previewView; }
|
PreviewView * GetView() { return previewView; }
|
||||||
|
@@ -25,12 +25,28 @@ PreviewView::PreviewView():
|
|||||||
v->c->Exit();
|
v->c->Exit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
openButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(75, 16), "Open");
|
openButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(50, 16), "Open");
|
||||||
openButton->SetAlignment(AlignLeft, AlignMiddle);
|
openButton->SetAlignment(AlignLeft, AlignMiddle);
|
||||||
openButton->SetIcon(IconOpen);
|
openButton->SetIcon(IconOpen);
|
||||||
openButton->SetActionCallback(new OpenAction(this));
|
openButton->SetActionCallback(new OpenAction(this));
|
||||||
AddComponent(openButton);
|
AddComponent(openButton);
|
||||||
|
|
||||||
|
class BrowserOpenAction: public ui::ButtonAction
|
||||||
|
{
|
||||||
|
PreviewView * v;
|
||||||
|
public:
|
||||||
|
BrowserOpenAction(PreviewView * v_){ v = v_; }
|
||||||
|
virtual void ActionCallback(ui::Button * sender)
|
||||||
|
{
|
||||||
|
v->c->OpenInBrowser();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
browserOpenButton = new ui::Button(ui::Point((XRES/2)-90, Size.Y-16), ui::Point(90, 16), "Open in browser");
|
||||||
|
browserOpenButton->SetAlignment(AlignLeft, AlignMiddle);
|
||||||
|
browserOpenButton->SetIcon(IconOpen);
|
||||||
|
browserOpenButton->SetActionCallback(new BrowserOpenAction(this));
|
||||||
|
AddComponent(browserOpenButton);
|
||||||
|
|
||||||
saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+15), ui::Point(100, 16), "");
|
saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+15), ui::Point(100, 16), "");
|
||||||
saveNameLabel->SetAlignment(AlignLeft, AlignBottom);
|
saveNameLabel->SetAlignment(AlignLeft, AlignBottom);
|
||||||
AddComponent(saveNameLabel);
|
AddComponent(saveNameLabel);
|
||||||
|
@@ -20,6 +20,7 @@ class PreviewView: public ui::Window {
|
|||||||
PreviewController * c;
|
PreviewController * c;
|
||||||
Thumbnail * savePreview;
|
Thumbnail * savePreview;
|
||||||
ui::Button * openButton;
|
ui::Button * openButton;
|
||||||
|
ui::Button * browserOpenButton;
|
||||||
ui::Label * saveNameLabel;
|
ui::Label * saveNameLabel;
|
||||||
ui::Label * authorDateLabel;
|
ui::Label * authorDateLabel;
|
||||||
int votesUp;
|
int votesUp;
|
||||||
|
Reference in New Issue
Block a user