summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-17 15:11:19 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-17 15:11:19 +0000
commitd0c97b98e477cfdf46ed7f36fd16c64f7943d551 (patch)
tree156acefaae842888432f923257b76bad12a16672 /src/gui
parentd9593657605b2e286b478718c89bcbe7cd341c43 (diff)
downloadmana-d0c97b98e477cfdf46ed7f36fd16c64f7943d551.tar.gz
mana-d0c97b98e477cfdf46ed7f36fd16c64f7943d551.tar.bz2
mana-d0c97b98e477cfdf46ed7f36fd16c64f7943d551.tar.xz
mana-d0c97b98e477cfdf46ed7f36fd16c64f7943d551.zip
Committing Allegro -> SDL switch, hugely breaking the game.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/allegroinput.cpp70
-rw-r--r--src/gui/allegroinput.h49
-rw-r--r--src/gui/char_select.cpp21
-rw-r--r--src/gui/char_server.cpp19
-rw-r--r--src/gui/chat.cpp10
-rw-r--r--src/gui/checkbox.cpp2
-rw-r--r--src/gui/gui.cpp15
-rw-r--r--src/gui/gui.h19
-rw-r--r--src/gui/inventory.cpp4
-rw-r--r--src/gui/login.cpp25
-rw-r--r--src/gui/playerbox.cpp4
-rw-r--r--src/gui/progressbar.cpp4
-rw-r--r--src/gui/radiobutton.cpp2
-rw-r--r--src/gui/setup.cpp11
-rw-r--r--src/gui/setup.h1
-rw-r--r--src/gui/slider.cpp8
-rw-r--r--src/gui/window.cpp2
17 files changed, 90 insertions, 176 deletions
diff --git a/src/gui/allegroinput.cpp b/src/gui/allegroinput.cpp
deleted file mode 100644
index 8ca077c1..00000000
--- a/src/gui/allegroinput.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#include "allegroinput.h"
-#include "../game.h"
-#include <allegro.h>
-
-AllegroInput::AllegroInput() :
- gcn::AllegroInput()
-{
-}
-
-void AllegroInput::pollKeyInput()
-{
- int unicode, scancode;
-
- if (keyboard_needs_poll())
- {
- poll_keyboard();
- }
-
- while (keypressed())
- {
- unicode = ureadkey(&scancode);
-
- if (!handle_key(unicode, scancode))
- {
- gcn::Key keyObj = convertToKey(scancode, unicode);
- mKeyQueue.push(gcn::KeyInput(keyObj, gcn::KeyInput::PRESS));
- mPressedKeys[scancode] = keyObj;
- }
- }
-
- // Check for released keys
- std::map<int, gcn::Key>::iterator iter, tempIter;
- for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); )
- {
- if (!key[iter->first])
- {
- mKeyQueue.push(gcn::KeyInput(iter->second, gcn::KeyInput::RELEASE));
- tempIter = iter;
- iter++;
- mPressedKeys.erase(tempIter);
- }
- else
- {
- iter++;
- }
- }
-}
diff --git a/src/gui/allegroinput.h b/src/gui/allegroinput.h
deleted file mode 100644
index ab1a1301..00000000
--- a/src/gui/allegroinput.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#ifndef _TMW_ALLEGRO_INPUT_H__
-#define _TMW_ALLEGRO_INPUT_H__
-
-#include <guichan.hpp>
-#include <guichan/allegro.hpp>
-
-/**
- * Allegro input handler that gives us a chance to handle some shortkeys.
- *
- * \ingroup GUI
- */
-class AllegroInput : public gcn::AllegroInput
-{
- public:
- /**
- * Constructor.
- */
- AllegroInput();
-
- /**
- * Polls key input.
- */
- void pollKeyInput();
-};
-
-#endif
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index ac644f3a..3e509727 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -222,7 +222,8 @@ void CharSelectDialog::serverCharSelect()
}
char_ID = RFIFOL(2);
memset(map_path, '\0', 480);
- append_filename(map_path, "./data/map/", RFIFOP(6), 480);
+ strcat(map_path, "./data/map/");
+ strncat(map_path, RFIFOP(6), 479 - strlen(map_path));
map_address = RFIFOL(22);
map_port = RFIFOW(26);
state = GAME;
@@ -430,20 +431,32 @@ void charSelect()
state = CHAR_SELECT;
- while (!key[KEY_ESC] && !key[KEY_ENTER] && state == CHAR_SELECT)
+ while (/*!key[KEY_ESC] && !key[KEY_ENTER] &&*/ state == CHAR_SELECT)
{
+ // Handle SDL events
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch (event.type) {
+ case SDL_QUIT:
+ state = EXIT;
+ break;
+ }
+
+ guiInput->pushInput(event);
+ }
+
if (n_character > 0) {
sel->setPlayerInfo(char_info);
}
// Draw background
- login_wallpaper->draw(buffer, 0, 0);
+ login_wallpaper->draw(screen, 0, 0);
gui->logic();
gui->draw();
// Draw to screen
- blit(buffer, screen, 0, 0, 0, 0, 800, 600);
+ guiGraphics->updateScreen();
}
delete sel;
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 4178a8e5..5b3992f1 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -116,11 +116,24 @@ void char_server() {
state = LOGIN;
showServerList = 1;
- while (showServerList) {
- login_wallpaper->draw(buffer, 0, 0);
+ while (showServerList)
+ {
+ // Handle SDL events
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch (event.type) {
+ case SDL_QUIT:
+ state = EXIT;
+ break;
+ }
+
+ guiInput->pushInput(event);
+ }
+
+ login_wallpaper->draw(screen, 0, 0);
gui->logic();
gui->draw();
- blit(buffer, screen, 0, 0, 0, 0, 800, 600);
+ guiGraphics->updateScreen();
}
delete dialog;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 4d1f23ce..8c08b545 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -95,11 +95,11 @@ void ChatBox::draw(gcn::Graphics *graphics)
graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
getAbsolutePosition(x, y);
- set_trans_blender(0, 0, 0, 100);
- drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
- rectfill(buffer, x, y, x + getWidth(), y + getHeight(),
- makecol(255, 255, 255));
- drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
+ //set_trans_blender(0, 0, 0, 100);
+ //drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
+ //rectfill(buffer, x, y, x + getWidth(), y + getHeight(),
+ // makecol(255, 255, 255));
+ //drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
for (iter = chatlog.begin(); iter != chatlog.end(); iter++) {
line = *iter;
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index 25ae93b4..5eced992 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -57,6 +57,6 @@ void CheckBox::drawBox(gcn::Graphics* graphics) {
x += 2;
y += 2;
if (box != NULL) {
- box->draw(buffer, x, y);
+ box->draw(screen, x, y);
}
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index dd4216e5..c9742b05 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -22,13 +22,13 @@
*/
#include "gui.h"
-#include "allegroinput.h"
#include "window.h"
#include "windowcontainer.h"
// Guichan stuff
Gui *gui;
-gcn::AllegroGraphics *guiGraphics; // Graphics driver
+Graphics *guiGraphics; // Graphics driver
+gcn::SDLInput *guiInput; // GUI input
WindowContainer *guiTop; // The top container
Gui::Gui(Graphics *graphics)
@@ -37,15 +37,15 @@ Gui::Gui(Graphics *graphics)
guiGraphics = graphics;
// Set input
- guiInput = new AllegroInput();
+ guiInput = new gcn::SDLInput();
// Set image loader
- imageLoader = new gcn::AllegroImageLoader();
+ imageLoader = new gcn::SDLImageLoader();
gcn::Image::setImageLoader(imageLoader);
// Initialize top GUI widget
guiTop = new WindowContainer();
- guiTop->setDimension(gcn::Rectangle(0, 0, SCREEN_W, SCREEN_H));
+ guiTop->setDimension(gcn::Rectangle(0, 0, screen->w, screen->h));
guiTop->setOpaque(false);
Window::setWindowContainer(guiTop);
@@ -67,14 +67,11 @@ Gui::~Gui()
delete guiTop;
delete imageLoader;
delete guiInput;
- delete guiGraphics;
delete focusHandler;
}
void Gui::logic()
{
- guiInput->_pollInput();
-
while (!guiInput->isMouseQueueEmpty())
{
gcn::MouseInput mi = guiInput->dequeueMouseInput();
@@ -157,7 +154,7 @@ void Gui::draw()
guiGraphics->popClipArea();
// Draw the mouse
- draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);
+ //draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);
guiGraphics->_endDraw();
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 3d42087b..cd37ae63 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -25,8 +25,7 @@
#define _TMW_GUI
#include <guichan.hpp>
-#include <guichan/allegro.hpp>
-#include <allegro.h>
+#include <guichan/sdl.hpp>
#include <string.h>
#include "windowcontainer.h"
#include "../graphic/graphic.h"
@@ -75,19 +74,19 @@ class Gui
void draw();
private:
- gcn::Gui* gui; /**< The GUI system */
- gcn::Input* guiInput; /**< Input driver */
- gcn::ImageLoader* imageLoader; /**< For loading images */
- gcn::ImageFont* guiFont; /**< The global GUI font */
+ gcn::Gui *gui; /**< The GUI system */
+ gcn::ImageLoader *imageLoader; /**< For loading images */
+ gcn::ImageFont *guiFont; /**< The global GUI font */
bool topHasMouse;
- gcn::FocusHandler* focusHandler;
+ gcn::FocusHandler *focusHandler;
};
-extern Gui* gui;
-extern WindowContainer* guiTop; // The top container
-extern gcn::AllegroGraphics* guiGraphics; // Graphics driver
+extern Gui *gui;
+extern WindowContainer *guiTop; // The top container
+extern Graphics *guiGraphics; // Graphics driver
+extern gcn::SDLInput *guiInput; // GUI input
/** Initialize gui system */
void init_gui(Graphics *graphics);
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index dcaedc6f..c7f7aec8 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -55,12 +55,10 @@ void InventoryWindow::draw(gcn::Graphics *graphics)
// Draw window graphics
Window::draw(graphics);
- BITMAP *target = ((Graphics*)graphics)->getTarget();
-
for (int i = 0; i < INVENTORY_SIZE; i++) {
if (items[i].quantity > 0) {
if (items[i].id >= 501 && items[i].id <= 511) {
- itemset->spriteset[items[i].id - 501]->draw(target,
+ itemset->spriteset[items[i].id - 501]->draw(screen,
x + 24 * i,
y + 26);
}
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 13a8c2f3..b5104204 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -130,14 +130,27 @@ void LoginDialog::action(const std::string& eventId)
void login() {
LoginDialog *dialog = new LoginDialog();
- while (state == LOGIN) {
- login_wallpaper->draw(buffer, 0, 0);
+ while (state == LOGIN)
+ {
+ // Handle SDL events
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch (event.type) {
+ case SDL_QUIT:
+ state = EXIT;
+ break;
+ }
+
+ guiInput->pushInput(event);
+ }
+
+ login_wallpaper->draw(screen, 0, 0);
gui->logic();
gui->draw();
- blit(buffer, screen, 0, 0, 0, 0, 800, 600);
- if (key[KEY_ESC]) {
- state = EXIT;
- }
+ guiGraphics->updateScreen();
+ //if (key[KEY_ESC]) {
+ // state = EXIT;
+ //}
}
delete dialog;
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index 9efb9bad..70715729 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -58,12 +58,12 @@ void PlayerBox::draw(gcn::Graphics *graphics)
getAbsolutePosition(x, y);
// Draw character
- playerset->spriteset[0]->draw(buffer, x - 25, y - 25);
+ playerset->spriteset[0]->draw(screen, x - 25, y - 25);
// Draw his hair
int hf = hairColor + 40 * (hairStyle);
if (hf >= 0 && hf < (int)hairset->spriteset.size()) {
- hairset->spriteset[hf]->draw(buffer, x + 37, y + 5);
+ hairset->spriteset[hf]->draw(screen, x + 37, y + 5);
}
}
}
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 55fadd60..fdaefa73 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -40,7 +40,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
{
int absx, absy;
getAbsolutePosition(absx, absy);
-
+ /*
// outer bar
int MyColor = makecol(abs(Red-70), abs(Green-70), abs(Blue-70));
hline(buffer, absx+X+7, absy+Y, absx+X+Width, MyColor);
@@ -75,7 +75,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
line(buffer, absx+X+7, absy+Y+1, absx+X+2, absy+Y+7-1, MyColor);
//rectfill(buffer, absx+7, absy+7, absx+39, absy+9, MyColor);
-
+ */
/*
if (progress != 0) {
masked_blit(gui_skin.bar.bg.grid[3], buffer,
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index 4e90cbb1..ef84bbc2 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -57,6 +57,6 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
x += 2;
y += 2;
if (box != NULL) {
- box->draw(buffer, x, y);
+ box->draw(screen, x, y);
}
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index e9675ab3..bfb619c2 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -34,6 +34,7 @@
#include "radiobutton.h"
#include "ok_dialog.h"
#include "../main.h"
+#include <SDL.h>
#ifndef WIN32
extern Sound sound;
@@ -141,15 +142,17 @@ void Setup::action(const std::string& eventId)
if (fsCheckBox->isMarked() && config.getValue("screen", 0) == 2)
{
config.setValue("screen", 1);
- set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,
- modes[sel].height, modes[sel].width, 0, 0);
+ SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+ //set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,
+ // modes[sel].height, modes[sel].width, 0, 0);
}
else if (!fsCheckBox->isMarked() && config.getValue("screen", 0) == 1)
{
config.setValue("screen", 2);
- set_gfx_mode(GFX_AUTODETECT_WINDOWED,
- modes[sel].height, modes[sel].width, 0, 0);
+ SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+ //set_gfx_mode(GFX_AUTODETECT_WINDOWED,
+ // modes[sel].height, modes[sel].width, 0, 0);
}
// Sound settings
diff --git a/src/gui/setup.h b/src/gui/setup.h
index a1b00ea1..20540aa2 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -27,7 +27,6 @@
#include "gui.h"
#include "../graphic/graphic.h"
#include "../sound/sound.h"
-#include <allegro.h>
/**
* The list model for mode list.
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index ca6d547c..2d07d661 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -80,15 +80,15 @@ void Slider::draw(gcn::Graphics *graphics)
y += (h - hStart->getHeight()) / 2;
- hStart->draw(buffer, x, y);
+ hStart->draw(screen, x, y);
w -= hStart->getWidth() + hEnd->getWidth();
x += hStart->getWidth();
- hMid->drawPattern(buffer, x, y, w, hMid->getHeight());
+ hMid->drawPattern(screen, x, y, w, hMid->getHeight());
x += w;
- hEnd->draw(buffer, x, y);
+ hEnd->draw(screen, x, y);
drawMarker(graphics);
}
@@ -102,5 +102,5 @@ void Slider::drawMarker(gcn::Graphics *graphics)
x += mMarkerPosition;
y += (h - hGrip->getHeight()) / 2;
- hGrip->draw(buffer, x, y);
+ hGrip->draw(screen, x, y);
}
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 34ced06a..ca788883 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -106,8 +106,6 @@ void Window::draw(gcn::Graphics* graphics)
getWidth(), getHeight() - titlebarHeight + 1));
// Skinned dialog render
- Graphics *gfx = (Graphics*)graphics;
- BITMAP *screen = gfx->getTarget();
int x, y;
getAbsolutePosition(x, y);