diff options
Diffstat (limited to 'src/interface.old')
| -rw-r--r-- | src/interface.old/Button.cpp | 127 | ||||
| -rw-r--r-- | src/interface.old/Component.cpp | 89 | ||||
| -rw-r--r-- | src/interface.old/ControlFactory.cpp | 11 | ||||
| -rw-r--r-- | src/interface.old/Panel.cpp | 23 | ||||
| -rw-r--r-- | src/interface.old/Sandbox.cpp | 76 | ||||
| -rw-r--r-- | src/interface.old/State.cpp | 233 | ||||
| -rw-r--r-- | src/interface.old/Window.cpp | 23 |
7 files changed, 0 insertions, 582 deletions
diff --git a/src/interface.old/Button.cpp b/src/interface.old/Button.cpp deleted file mode 100644 index a357c36..0000000 --- a/src/interface.old/Button.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Button.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include <iostream> - -#include "interface/Button.h" -#include "Graphics.h" - -namespace ui { - -Button::Button(int x, int y, int width, int height, const std::string& buttonText): - Component(x, y, width, height), - Toggleable(false), - ButtonText(buttonText), - isMouseInside(false), - isButtonDown(false), - state(false) -{ - -} - -void Button::Draw(void* userdata) -{ - Graphics * g = reinterpret_cast<Graphics*>(userdata); - //TODO: Cache text location, that way we don't have the text alignment code here - if(isButtonDown) - { - g->fillrect(X, Y, Width, Height, 255, 255, 255, 255); - g->drawtext(X+(Width-Graphics::textwidth((char *)ButtonText.c_str()))/2, Y+(Height-10)/2, ButtonText, 0, 0, 0, 255); - } - else - { - if(isMouseInside) - g->fillrect(X, Y, Width, Height, 20, 20, 20, 255); - g->drawrect(X, Y, Width, Height, 255, 255, 255, 255); - g->drawtext(X+(Width-Graphics::textwidth((char *)ButtonText.c_str()))/2, Y+(Height-10)/2, ButtonText, 255, 255, 255, 255); - } - /*sf::RenderWindow* rw = reinterpret_cast<sf::RenderWindow*>(userdata); //it better be a RenderWindow or so help your god - - //Draw component here - sf::Text textGraphic(ButtonText); - textGraphic.SetCharacterSize(11); - if(isButtonDown) - textGraphic.SetColor(sf::Color::Black); - else - textGraphic.SetColor(sf::Color::White); - sf::FloatRect tempRect = textGraphic.GetRect(); - textGraphic.SetPosition(ceil(X + Width/2 - tempRect.Width/2), ceil(Y + Height/2 - tempRect.Height/2)); - - if(isMouseInside) - { - if(isButtonDown) - rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::White, 2.f, sf::Color::Black)); - else - rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::Black, 2.f, sf::Color::White)); - } - else - { - if(isButtonDown) - rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::White, 2.f, sf::Color::Black)); - else - rw->Draw(sf::Shape::Rectangle(X+1, Y+1, Width-2, Width-2, sf::Color::Black, 1.f, sf::Color::White)); - } - - rw->Draw(textGraphic);*/ -} - -void Button::OnMouseUnclick(int x, int y, unsigned int button) -{ - if(button != 1) - { - return; //left click only! - } - - if(isButtonDown) - { - if(state) - { - state = false; - } - else - { - if(Toggleable) - { - state = true; - } - DoAction(); - } - } - - isButtonDown = false; -} - -void Button::OnMouseUp(int x, int y, unsigned int button) //mouse unclick is called before this -{ - if(button != 1) return; //left click only! - - isButtonDown = false; -} - -void Button::OnMouseClick(int x, int y, unsigned int button) -{ - if(button != 1) return; //left click only! - - isButtonDown = true; -} - -void Button::OnMouseEnter(int x, int y, int dx, int dy) -{ - isMouseInside = true; -} - -void Button::OnMouseLeave(int x, int y, int dx, int dy) -{ - isMouseInside = false; -} - -void Button::DoAction() -{ - std::cout << "Do action!"<<std::endl; -} - -} /* namespace ui */ diff --git a/src/interface.old/Component.cpp b/src/interface.old/Component.cpp deleted file mode 100644 index 48a329b..0000000 --- a/src/interface.old/Component.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Component.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include "interface/Component.h" - -namespace ui { - -Component::Component(int x, int y, int width, int height): - X(x), - Y(y), - Width(width), - Height(height), - Enabled(true), - Visible(true) -{ -} - -Component::~Component() -{ -} - -void Component::Draw(void* userdata) -{ -} - -void Component::Tick(float dt) -{ -} - -void Component::OnKeyPress(int key, bool shift, bool ctrl, bool alt) -{ -} - -void Component::OnKeyRelease(int key, bool shift, bool ctrl, bool alt) -{ -} - -void Component::OnMouseEnter(int localx, int localy, int dx, int dy) -{ -} - -void Component::OnMouseLeave(int localx, int localy, int dx, int dy) -{ -} - -void Component::OnMouseClick(int localx, int localy, unsigned int button) -{ -} - -void Component::OnMouseUnclick(int localx, int localy, unsigned int button) -{ -} - -void Component::OnMouseDown(int localx, int localy, unsigned int button) -{ -} - -void Component::OnMouseHover(int localx, int localy) -{ -} - -void Component::OnMouseMoved(int localx, int localy, int dx, int dy) -{ -} - -void Component::OnMouseMovedInside(int localx, int localy, int dx, int dy) -{ -} - -void Component::OnMouseUp(int localx, int localy, unsigned int button) -{ -} - -void Component::OnMouseWheel(int localx, int localy, int d) -{ -} - -void Component::OnMouseWheelInside(int localx, int localy, int d) -{ -} - -void Component::OnMouseWheelFocused(int localx, int localy, int d) -{ -} -} /* namespace ui */ diff --git a/src/interface.old/ControlFactory.cpp b/src/interface.old/ControlFactory.cpp deleted file mode 100644 index 300ceba..0000000 --- a/src/interface.old/ControlFactory.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "interface/ControlFactory.h" -#include "interface/Button.h" -#include "interface/Panel.h" -#include "interface/Window.h" - -ui::Panel * ControlFactory::MainMenu(GameSession * session, int x, int y, int width, int height) -{ - ui::Panel * mainMenu = new ui::Panel(x, y, width, height); - //mainMenu->Add(new ui::Button(0, 0, 20, 20, "Turd")); - return mainMenu; -} diff --git a/src/interface.old/Panel.cpp b/src/interface.old/Panel.cpp deleted file mode 100644 index 164bfa3..0000000 --- a/src/interface.old/Panel.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Panel.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include "interface/Panel.h" - -namespace ui { - -Panel::Panel(int x, int y, int width, int height): - Component(x, y, width, height) -{ - // TODO Auto-generated constructor stub - -} - -Panel::~Panel() { - // TODO Auto-generated destructor stub -} - -} /* namespace ui */ diff --git a/src/interface.old/Sandbox.cpp b/src/interface.old/Sandbox.cpp deleted file mode 100644 index 5e29bae..0000000 --- a/src/interface.old/Sandbox.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Sandbox.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include <iostream> - -#include "Config.h" - -#include "interface/Sandbox.h" -#include "interface/Component.h" -#include "Renderer.h" -#include "Simulation.h" - -namespace ui { - -Sandbox::Sandbox(): - Component(0, 0, XRES, YRES), - ren(NULL), - isMouseDown(false), - activeElement(1) -{ - sim = new Simulation(); -} - -Simulation * Sandbox::GetSimulation() -{ - return sim; -} - -void Sandbox::OnMouseMovedInside(int localx, int localy, int dx, int dy) -{ - if(isMouseDown) - { - sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0); - lastCoordX = localx; - lastCoordY = localy; - } -} - -void Sandbox::OnMouseDown(int localx, int localy, unsigned int button) -{ - sim->create_line(localx, localy, localx, localy, 2, 2, activeElement, 0); - lastCoordX = localx; - lastCoordY = localy; - isMouseDown = true; -} - -void Sandbox::OnMouseUp(int localx, int localy, unsigned int button) -{ - sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0); - lastCoordX = localx; - lastCoordY = localy; - isMouseDown = false; -} - -void Sandbox::Draw(void* userdata) -{ - Graphics * g = reinterpret_cast<Graphics*>(userdata); - if(!ren) - ren = new Renderer(g, sim); - ren->render_parts(); -} - -void Sandbox::Tick(float delta) -{ - sim->update_particles(); -} - -Sandbox::~Sandbox() { - // TODO Auto-generated destructor stub -} - -} /* namespace ui */ diff --git a/src/interface.old/State.cpp b/src/interface.old/State.cpp deleted file mode 100644 index 2828751..0000000 --- a/src/interface.old/State.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * State.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include <vector> -#include <iostream> -#include <cstring> - -#include "interface/State.h" - -namespace ui { - -State::State(int w, int h): - mouseX(0), - mouseY(0), - mouseXP(0), - mouseYP(0), - width(w), - height(h), - Components() -{ -} - -State::~State() -{ - //Components.~vector(); // just in case // devnote : Nope.jpg Nate :3 -frankbro -} - -void State::Add(Component* child) -{ - Components.push_back(child); - child->Parent = this; -} - -void State::Remove(Component* child) -{ - for(int i = 0; i < Components.size(); i++) - if(Components[i] == child) - { - Components.erase(Components.begin() + i); - break; - } -} - -void State::Draw(void* userdata) -{ - //draw - for(int i = 0; i < Components.size(); i++) - { - if(Components[i]->Visible) - { - if(AllowExclusiveDrawing) - { - Components[i]->Draw(userdata); - } - else if( - Components[i]->X + Components[i]->Width >= 0 && - Components[i]->Y + Components[i]->Height >= 0 && - Components[i]->X < width && - Components[i]->Y < height ) - { - Components[i]->Draw(userdata); - } - } - } -} - -void State::Tick(float dt) -{ - //on mouse hover - for(int i = 0; i < Components.size(); i++) - if( mouseX >= Components[i]->X && - mouseY >= Components[i]->Y && - mouseX < Components[i]->X + Components[i]->Width && - mouseY < Components[i]->Y + Components[i]->Height ) - { - if(Components[i]->Enabled) - { - Components[i]->OnMouseHover(mouseX, mouseY); - } - break; - } - - //tick - for(int i = 0; i < Components.size(); i++) - Components[i]->Tick(dt); -} - -void State::OnKeyPress(int key, bool shift, bool ctrl, bool alt) -{ - //on key press - if(focusedComponent_ != NULL) - if(focusedComponent_->Enabled) - focusedComponent_->OnKeyPress(key, shift, ctrl, alt); -} - -void State::OnKeyRelease(int key, bool shift, bool ctrl, bool alt) -{ - //on key unpress - if(focusedComponent_ != NULL) - if(focusedComponent_->Enabled) - focusedComponent_->OnKeyRelease(key, shift, ctrl, alt); -} - -void State::OnMouseDown(int x, int y, unsigned int button) -{ - //on mouse click - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height) - { - Components[i]->OnMouseClick(x - Components[i]->X, y - Components[i]->Y, button); - this->focusedComponent_ = Components[i]; //set this component as the focused component - break; - } - - //on mouse down - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - Components[i]->OnMouseDown(x - Components[i]->X, y - Components[i]->Y, button); -} - -void State::OnMouseMove(int x, int y) -{ - //update mouse coords - mouseX = x; - mouseY = y; - - //on mouse move (if true, and inside) - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - { - int localX = x - Components[i]->X; - int localY = y - Components[i]->Y; - int localXP = mouseXP - Components[i]->X; - int localYP = mouseYP - Components[i]->Y; - int dx = x - mouseXP; - int dy = x - mouseYP; - - Components[i]->OnMouseMoved(localX, localY, dx, dy); - - //is the mouse inside - if(localX >= 0 && - localY >= 0 && - localX < Components[i]->Width && - localY < Components[i]->Height ) - { - //was the mouse outside last tick? - if(localXP < 0 || - localXP >= Components[i]->Width || - localYP < 0 || - localYP >= Components[i]->Height ) - { - Components[i]->OnMouseEnter(localX, localY, dx, dy); - } - - Components[i]->OnMouseMovedInside(localX, localY, dx, dy); - - break; //found the top-most component under mouse, break that shit - } - //not inside, let's see if it used to be inside last tick - else if (localXP >= 0 && - localYP >= 0 && - localXP < Components[i]->Width && - localYP < Components[i]->Height ) - { - Components[i]->OnMouseLeave(localX, localY, x - mouseXP, y - mouseYP); - } - } - else //is locked - { - int localX = x - Components[i]->X; - int localY = y - Components[i]->Y; - - //is the mouse inside - if(localX >= 0 && - localY >= 0 && - localX < Components[i]->Width && - localY < Components[i]->Height ) - { - break; //it's the top-most component under the mouse, we don't want to go under it. - } - } - // end of for loop here - - //set the previous mouse coords - mouseXP = x; - mouseYP = y; -} - -void State::OnMouseUp(int x, int y, unsigned int button) -{ - //on mouse unclick - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height) - { - Components[i]->OnMouseUnclick(x - Components[i]->X, y - Components[i]->Y, button); - break; - } - - //on mouse up - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - Components[i]->OnMouseUp(x - Components[i]->X, y - Components[i]->Y, button); -} - -void State::OnMouseWheel(int x, int y, int d) -{ - //focused mouse wheel - if(focusedComponent_ != NULL) - focusedComponent_->OnMouseWheelFocused(x - focusedComponent_->X, y - focusedComponent_->Y, d); - - //mouse wheel inside - for(int i = Components.size() - 1; i > -1 ; i--) - if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height) - { - if(Components[i]->Enabled) - Components[i]->OnMouseWheelInside(x - Components[i]->X, y - Components[i]->Y, d); - break; //found top-most component under mouse - } - - //on mouse wheel - for(int i = Components.size() - 1; i > -1 ; i--) - if(Components[i]->Enabled) - Components[i]->OnMouseWheel(x - Components[i]->X, y - Components[i]->Y, d); -} - - -} /* namespace ui */ diff --git a/src/interface.old/Window.cpp b/src/interface.old/Window.cpp deleted file mode 100644 index 624bf9a..0000000 --- a/src/interface.old/Window.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Window.cpp - * - * Created on: Jan 8, 2012 - * Author: Simon - */ - -#include "interface/Window.h" - -namespace ui { - -Window::Window(): - State(width, height) -{ - // TODO Auto-generated constructor stub - -} - -Window::~Window() { - // TODO Auto-generated destructor stub -} - -} /* namespace ui */ |
