summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-15 13:29:16 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-15 13:29:16 +0000
commitf06b86893e610276d1deac4c2dd3c0247d62b44d (patch)
treef4d24df364c33e437c4979d5ddea812129a40300 /src
parent192f17745eb2c3bba18b066f2d01ca771b3cd4d8 (diff)
downloadmana-client-f06b86893e610276d1deac4c2dd3c0247d62b44d.tar.gz
mana-client-f06b86893e610276d1deac4c2dd3c0247d62b44d.tar.bz2
mana-client-f06b86893e610276d1deac4c2dd3c0247d62b44d.tar.xz
mana-client-f06b86893e610276d1deac4c2dd3c0247d62b44d.zip
Updated layout and contents of FAQ a bit, fixed debug path and mouse rendering
in OpenGL mode, and some general cleanups.
Diffstat (limited to 'src')
-rw-r--r--src/graphic/graphic.cpp75
-rw-r--r--src/gui/char_select.cpp2
-rw-r--r--src/gui/char_server.cpp4
-rw-r--r--src/gui/gui.cpp12
-rw-r--r--src/gui/gui.h5
-rw-r--r--src/gui/login.cpp2
-rw-r--r--src/main.cpp15
7 files changed, 48 insertions, 67 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 29bf3596..2e681fb0 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -162,7 +162,9 @@ Graphics::Graphics():
setTarget(SDL_GetVideoSurface());
#endif
-#ifndef USE_OPENGL
+ // Hide the system mouse cursor
+ SDL_ShowCursor(SDL_DISABLE);
+
// Load the mouse cursor
ResourceManager *resman = ResourceManager::getInstance();
mouseCursor = resman->getImage("core/graphics/gui/mouse.png", IMG_ALPHA);
@@ -170,12 +172,14 @@ Graphics::Graphics():
error("Unable to load mouse cursor.");
}
- // Hide the system mouse cursor
- SDL_ShowCursor(SDL_DISABLE);
-#endif
+ // Initialize for drawing
+ _beginDraw();
}
-Graphics::~Graphics() {
+Graphics::~Graphics()
+{
+ // Deinitialize for drawing
+ _endDraw();
}
void Graphics::drawImageRect(
@@ -230,17 +234,17 @@ void Graphics::drawImageRect(
void Graphics::updateScreen()
{
+ // Draw mouse before flipping
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
+ mouseCursor->draw(screen, mouseX - 5, mouseY - 2);
+
#ifdef USE_OPENGL
glFlush();
glFinish();
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT);
#else
- // Draw mouse before flipping
- int mouseX, mouseY;
- SDL_GetMouseState(&mouseX, &mouseY);
- mouseCursor->draw(screen, mouseX - 5, mouseY - 2);
-
SDL_Flip(screen);
#endif
}
@@ -251,7 +255,8 @@ Engine::Engine()
// Initializes GUI
chatInput = new TextField();
chatInput->setPosition(chatInput->getBorderSize(),
- screen->h - chatInput->getHeight() - chatInput->getBorderSize() -1);
+ screen->h - chatInput->getHeight() -
+ chatInput->getBorderSize());
chatInput->setWidth(592 - 2 * chatInput->getBorderSize());
ChatListener *chatListener = new ChatListener();
@@ -285,7 +290,8 @@ Engine::Engine()
inventoryWindow = new InventoryWindow();
inventoryWindow->setVisible(false);
- inventoryWindow->setPosition(screen->w - statusWindow->getWidth() - inventoryWindow->getWidth() - 10, 5);
+ inventoryWindow->setPosition(screen->w - statusWindow->getWidth() -
+ inventoryWindow->getWidth() - 10, 5);
npcTextDialog = new NpcTextDialog();
npcTextDialog->setVisible(false);
@@ -298,7 +304,9 @@ Engine::Engine()
statsWindow = new StatsWindow();
statsWindow->setVisible(false);
- statsWindow->setPosition(screen->w - 5 - statsWindow->getWidth(), statusWindow->getHeight() + 20);
+ statsWindow->setPosition(
+ screen->w - 5 - statsWindow->getWidth(),
+ statusWindow->getHeight() + 20);
setupWindow = new Setup();
setupWindow->setVisible(false);
@@ -356,8 +364,6 @@ Engine::~Engine()
void Engine::draw()
{
- guiGraphics->_beginDraw();
-
// Get the current mouse position
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
@@ -395,7 +401,8 @@ void Engine::draw()
// Draw nodes
std::list<Being*>::iterator beingIterator = beings.begin();
- while (beingIterator != beings.end()) {
+ while (beingIterator != beings.end())
+ {
Being *being = (*beingIterator);
unsigned short x = being->x;
@@ -403,11 +410,12 @@ void Engine::draw()
unsigned char dir = being->direction / 2;
int sx = x - camera_x;
int sy = y - camera_y;
-
+
#ifdef DEBUG
- //rect(screen, sx*32, sy*32, sx*32+32, sy*32+32, makecol(0,0,255));
+ guiGraphics->setColor(gcn::Color(0, 0, 255));
+ guiGraphics->drawRectangle(gcn::Rectangle(sx * 32, sy * 32, 32, 32));
#endif
-
+
if ((being->job >= 100) && (being->job <= 110)) { // Draw a NPC
npcset->spriteset[4 * (being->job - 100) + dir]->draw(screen,
sx * 32 - 8 - offset_x,
@@ -514,37 +522,36 @@ void Engine::draw()
if (tile > 0 && tile < (int)tileset->spriteset.size()) {
tileset->spriteset[tile]->draw(
screen, i * 32 - offset_x, j * 32 - offset_y);
- }
-#ifdef DEBUG
- //rect(screen, i * 32 - offset_x, j * 32 - offset_y,
- // i * 32 - offset_x + 32, j * 32 - offset_y + 32,
- // makecol(0,0,0));
+
+#ifdef DEBUG
+ guiGraphics->setColor(gcn::Color(0, 0, 0));
+ guiGraphics->drawRectangle(gcn::Rectangle(
+ i * 32 - offset_x, j * 32 - offset_y, 32, 32));
#endif
+ }
}
}
+ // Find a path from the player to the mouse, and draw it. This is for debug
+ // purposes.
if (displayPathToMouse)
{
- // Draw a debug path
PATH_NODE *debugPath = tiledMap.findPath(
player_node->x, player_node->y,
mouseX / 32 + camera_x, mouseY / 32 + camera_y);
while (debugPath)
{
- SDL_Rect destRect;
- destRect.x = (debugPath->x - camera_x) * 32 - offset_x + 12;
- destRect.y = (debugPath->y - camera_y) * 32 - offset_y + 12;
- destRect.w = 8;
- destRect.h = 8;
- SDL_FillRect(screen, &destRect,
- SDL_MapRGB(screen->format, 255, 0, 0));
+ int squareX = (debugPath->x - camera_x) * 32 - offset_x + 12;
+ int squareY = (debugPath->y - camera_y) * 32 - offset_y + 12;
+ guiGraphics->setColor(gcn::Color(255, 0, 0));
+ guiGraphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
Tile *tile = tiledMap.getTile(debugPath->x, debugPath->y);
std::stringstream cost;
cost << tile->Gcost;
- guiGraphics->drawText(cost.str(), destRect.x + 4, destRect.y + 12,
+ guiGraphics->drawText(cost.str(), squareX + 4, squareY + 12,
gcn::Graphics::CENTER);
// Move to the next node
@@ -595,6 +602,4 @@ void Engine::draw()
(mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y);
debugInfo->setCaption(debugStream.str());
debugInfo->adjustSize();
-
- guiGraphics->_endDraw();
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 24fa9c86..ba18a93d 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -452,10 +452,8 @@ void charSelect()
gui->logic();
- guiGraphics->_beginDraw();
login_wallpaper->draw(screen, 0, 0);
gui->draw();
- guiGraphics->_endDraw();
guiGraphics->updateScreen();
}
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 6cc45f3d..035f18fd 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -140,10 +140,8 @@ void char_server() {
gui->logic();
- guiGraphics->_beginDraw();
login_wallpaper->draw(screen, 0, 0);
gui->draw();
- guiGraphics->_endDraw();
guiGraphics->updateScreen();
}
@@ -205,7 +203,7 @@ void server_char_server(int serverIndex) {
}
state = CHAR_SELECT;
- log("CharServer: Player: %s (Packet ID: %x, Length: %d",
+ log("CharServer: Player: %s (Packet ID: %x, Length: %d)",
char_info->name, RFIFOW(0), RFIFOW(2));
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 6cc05910..cf4c5b36 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -156,24 +156,12 @@ void Gui::logic()
void Gui::draw()
{
- //guiGraphics->_beginDraw();
-
guiGraphics->pushClipArea(guiTop->getDimension());
guiTop->draw(guiGraphics);
guiGraphics->popClipArea();
-
- //guiGraphics->_endDraw();
}
void Gui::focusNone()
{
focusHandler->focusNone();
}
-
-void init_gui(Graphics *graphics) {
- gui = new Gui(graphics);
-}
-
-void gui_exit() {
- delete gui;
-}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 597cdb5c..6b678396 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -91,9 +91,4 @@ 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);
-
-void gui_exit();
-
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 5621f5b2..e5861a9b 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -154,10 +154,8 @@ void login() {
gui->logic();
- guiGraphics->_beginDraw();
login_wallpaper->draw(screen, 0, 0);
gui->draw();
- guiGraphics->_endDraw();
guiGraphics->updateScreen();
}
diff --git a/src/main.cpp b/src/main.cpp
index 043be40d..0c79affe 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -95,10 +95,6 @@ class InitWarningListener : public gcn::ActionListener {
}
} initWarningListener;
-void request_exit() {
- state = EXIT;
-}
-
/**
* Do all initialization stuff
*/
@@ -277,7 +273,7 @@ void init_engine()
playerset = new Spriteset(playerImg, 160, 120);
hairset = new Spriteset(hairImg, 40, 40);
- init_gui(graphics);
+ gui = new Gui(graphics);
state = LOGIN;
// initialize sound-engine and start playing intro-theme /-kth5
@@ -302,15 +298,18 @@ void init_engine()
}
/** Clear the engine */
-void exit_engine() {
+void exit_engine()
+{
config.write(dir);
delete[] dir;
- gui_exit();
+ delete gui;
+ delete graphics;
ResourceManager::deleteInstance();
}
/** Main */
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
init_engine();
SDL_Event event;