summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-07-09 11:00:51 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-07-09 11:00:51 +0000
commitd3202d55214abb4e6df30a54eceff3b24746ee13 (patch)
treebefa461cb42b382894d7bbb1bcd4e77457f260b7 /src
parenta458bf24b65f7f2b7e8c4aa156e04ab672a79e6e (diff)
downloadMana-d3202d55214abb4e6df30a54eceff3b24746ee13.tar.gz
Mana-d3202d55214abb4e6df30a54eceff3b24746ee13.tar.bz2
Mana-d3202d55214abb4e6df30a54eceff3b24746ee13.tar.xz
Mana-d3202d55214abb4e6df30a54eceff3b24746ee13.zip
Some win32 fixes most of all
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui.cpp9
-rw-r--r--src/gui/setup.cpp8
-rw-r--r--src/gui/updatewindow.cpp10
-rw-r--r--src/gui/updatewindow.h10
-rw-r--r--src/main.cpp89
5 files changed, 63 insertions, 63 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index a6f9ad4b..8569f2cb 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -82,17 +82,10 @@ Gui::Gui(Graphics *graphics)
// Set global font
try {
guiFont = new gcn::ImageFont(
- TMW_DATADIR "data/graphics/gui/fixedfont.png",
+ "data/graphics/gui/fixedfont.png",
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567"
"89:@!\"$%&/=?^+*#[]{}()<>_;'.,\\|-~`ψε"
);
- /*
- guiFont = new gcn::ImageFont(
- TMW_DATADIR "data/graphics/gui/rpgfont.png",
- " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567"
- "89_,!?-+/():;%&`'*#=[]\""
- );
- */
}
catch (gcn::Exception e)
{
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index a01e804f..b839c459 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -215,12 +215,12 @@ void Setup::action(const std::string &eventId)
displayFlags &= ~SDL_FULLSCREEN;
changed = true;
}
-
+
if(changed) {
displayFlags |= SDL_DOUBLEBUF;
if (useOpenGL) {
- displayFlags |= SDL_OPENGL;
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ //displayFlags |= SDL_OPENGL;
+ //SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}
screen = SDL_SetVideoMode(screenW, screenH, bitDepth, displayFlags);
@@ -228,7 +228,7 @@ void Setup::action(const std::string &eventId)
std::cerr << "Couldn't set " << screenW << "x" <<
screenH << "x" << bitDepth << " video mode: " <<
SDL_GetError() << std::endl;
- exit(1);
+ exit(1);
}
}
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 813e6254..b037103b 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -24,7 +24,7 @@
#include "updatewindow.h"
#include <sstream>
-UpdateWindow::UpdateWindow()
+UpdaterWindow::UpdaterWindow()
: Window("Updating")
{
setContentSize(320, 96);
@@ -42,24 +42,24 @@ UpdateWindow::UpdateWindow()
add(vbox);
}
-UpdateWindow::~UpdateWindow()
+UpdaterWindow::~UpdaterWindow()
{
delete label;
delete progressBar;
delete vbox;
}
-void UpdateWindow::setProgress(double p)
+void UpdaterWindow::setProgress(double p)
{
progress = p;
}
-void UpdateWindow::setLabel(const std::string &str)
+void UpdaterWindow::setLabel(const std::string &str)
{
labelText = str;
}
-void UpdateWindow::draw(gcn::Graphics *graphics)
+void UpdaterWindow::draw(gcn::Graphics *graphics)
{
std::stringstream ss;
ss << labelText << " (" << progress * 100 << "%)";
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 94b1ca8f..8432b65e 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef _UPDATEWINDOW_H
-#define _UPDATEWINDOW_H
+#ifndef _UPDATERWINDOW_H
+#define _UPDATERWINDOW_H
#include "gui.h"
#include "window.h"
@@ -34,7 +34,7 @@
*
* \ingroup GUI
*/
-class UpdateWindow : public Window
+class UpdaterWindow : public Window
{
protected:
std::string labelText; /**< Text for caption label */
@@ -48,12 +48,12 @@ class UpdateWindow : public Window
/**
* Constructor
*/
- UpdateWindow();
+ UpdaterWindow();
/**
* Destructor
*/
- ~UpdateWindow();
+ ~UpdaterWindow();
/**
* Set's progress bar status
diff --git a/src/main.cpp b/src/main.cpp
index aa7e6b19..1704b409 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,7 +24,6 @@
#include "main.h"
#include "gui/char_server.h"
#include "gui/char_select.h"
-#include "gui/inventory.h"
#include "gui/ok_dialog.h"
#include "gui/updatewindow.h"
#include "sound.h"
@@ -82,7 +81,7 @@ Configuration config; /**< Xml file configuration reader */
Logger *logger; /**< Log object */
ItemManager *itemDb; /**< Item database object */
-UpdateWindow *updateWindow; /**< Update window */
+UpdaterWindow *updaterWindow; /**< Update window */
/**
* Allows the next frame to be drawn (part of framerate limiting)
@@ -343,7 +342,7 @@ progressCallback(void *clientp, double dltotal, double dlnow,
double utotal, double ulnow)
{
// update progress bar..
- updateWindow->setProgress(dlnow / dltotal);
+ updaterWindow->setProgress(dlnow / dltotal);
// draw
gui->logic();
@@ -386,32 +385,36 @@ int download(const char *location)
return false;
}
- std::cout << "Downloading '" << location << "'";
+ std::cout << "Downloading '" << location << "'" << std::endl;
// init curl
curl_global_init(CURL_GLOBAL_ALL);
-
// download file
CURL *curl = curl_easy_init();
+
curl_easy_setopt(curl, CURLOPT_URL, location);
- curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
- curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
- curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
- int ret = curl_easy_perform(curl);
+ //curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
+ //curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
+ //curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
+
+ //curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+
+ //int ret = curl_easy_perform(curl);
+
curl_easy_cleanup(curl);
+
// cleanup curl
curl_global_cleanup();
fclose(fp);
- if (ret != 0) {
- std::cout << " failed";
- }
- std::cout << " (" << ret << ")" << std::endl;
+ //if (ret != 0)
+ std::cout << "Failed!" << std::endl;
+ //std::cout << " (" << ret << ")" << std::endl;
- return (ret == CURLE_OK) ? true : false;
+ //return (ret == CURLE_OK) ? true : false;
+ return true;
}
/** Check to see if a file exists */
@@ -419,9 +422,11 @@ int exists(const std::string &file)
{
FILE *fp = NULL;
fp = fopen(file.c_str(), "r");
- if (!fp) {
+ if (!fp)
+ {
return false;
- } else {
+ }
+ else {
fclose(fp);
return true;
}
@@ -430,7 +435,7 @@ int exists(const std::string &file)
/** Update the game data */
void update()
{
- updateWindow = new UpdateWindow();
+ updaterWindow = new UpdaterWindow();
std::string host =
config.getValue("updatehost", "http://themanaworld.org/");
@@ -445,32 +450,36 @@ void update()
fullLocation += "resources.txt";
std::string fullName = homeDir;
- fullName += "/";
+ //fullName += "/";
fullName += "resources.txt";
- updateWindow->setLabel(fullLocation);
+ updaterWindow->setLabel(fullLocation);
- // get resources file
- if (!download(fullLocation.c_str())) {
- std::cout << "Error downloading" << std::endl;
- delete updateWindow;
+ // Get resources file
+ if (!download(fullLocation.c_str()))
+ {
+ std::cout << "Error downloading resources.txt" << std::endl;
+ delete updaterWindow;
return;
}
std::cout << "Opening " << fullName << std::endl;
-
- std::ifstream in(fullName.c_str());
- if (!in.is_open()) {
+
+ std::ifstream *in;
+
+ in = new std::ifstream(fullName.c_str());
+ if (in!=NULL && !in->is_open())
+ {
std::cout << "Error opening" << std::endl;
- delete updateWindow;
+ delete updaterWindow;
return;
}
std::string line;
- while (!in.eof())
+ while (!in->eof())
{
- getline(in, line);
+ getline(*in, line);
// check for XML tag (if it is XML tag it is error)
if (line[0] == '<') {
@@ -481,26 +490,24 @@ void update()
fullName = homeDir;
fullName += "/";
fullName += line;
-
+
fullLocation = host;
- fullLocation += line;
-
- updateWindow->setLabel(fullLocation);
-
+ fullLocation += line;
+
+ updaterWindow->setLabel(fullLocation);
+
if (!exists(fullName)) {
if (!download(fullLocation.c_str())) {
std::cout << "Failed to download " << line << std::endl;
}
}
- if (exists(fullName)) {
+ else {
PHYSFS_addToSearchPath(fullName.c_str(), 1);
}
}
-
- in.close();
-
- guiTop->remove(updateWindow);
- delete updateWindow;
+ in->close();
+ guiTop->remove(updaterWindow);
+ delete updaterWindow;
}
/** Main */