diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-07 10:13:03 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-07 10:13:03 +0000 |
commit | 071877484ef493631592d9f10b6c4457097eca29 (patch) | |
tree | 2beb3921959350855a140d2e782cfdb4ec9380d6 | |
parent | 553e1d562af1413b9f28bf1c4b079d301349020e (diff) | |
download | mana-client-071877484ef493631592d9f10b6c4457097eca29.tar.gz mana-client-071877484ef493631592d9f10b6c4457097eca29.tar.bz2 mana-client-071877484ef493631592d9f10b6c4457097eca29.tar.xz mana-client-071877484ef493631592d9f10b6c4457097eca29.zip |
Removed --skipupdate option from Dev.Cpp project file, splitted the setup window into 3 tabs and added a joystick calibration tool.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | The Mana World.dev | 2 | ||||
-rw-r--r-- | src/game.cpp | 19 | ||||
-rw-r--r-- | src/gui/setup.cpp | 159 | ||||
-rw-r--r-- | src/gui/setup.h | 7 | ||||
-rw-r--r-- | src/main.cpp | 1 |
6 files changed, 140 insertions, 52 deletions
@@ -1,6 +1,10 @@ 2006-01-07 Eugenio Favalli <elvenprogrammer@gmail.com> * data/maps/new_9-1.tmx.gz: Crush fixed the issues reported on wiki. + * The Mana World.dev, src/game.cpp, src/gui/setup.cpp, src/gui/setup.h, + src/main.cpp: Removed --skipupdate option from Dev.Cpp project file, + splitted the setup window into 3 tabs and added a joystick calibration + tool. 2006-01-05 Björn Steinbrink <B.Steinbrink@gmx.de> diff --git a/The Mana World.dev b/The Mana World.dev index 5d6e5f97..654593f1 100644 --- a/The Mana World.dev +++ b/The Mana World.dev @@ -21,7 +21,7 @@ OverrideOutput=1 OverrideOutputName=tmw.exe HostApplication= Folders=graphic,graphic/header,graphic/source,gui,gui/header,gui/source,header,net,net/header,net/source,resources -CommandLine=--skipupdate +CommandLine= UseCustomMakefile=0 CustomMakefile= IncludeVersionInfo=1 diff --git a/src/game.cpp b/src/game.cpp index ee254d13..aa77847d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -301,8 +301,6 @@ void do_init() player_node->setWeapon(player_info->weapon); - remove("packet.list"); - // Initialize joypad SDL_InitSubSystem(SDL_INIT_JOYSTICK); //SDL_JoystickEventState(SDL_ENABLE); @@ -423,23 +421,26 @@ void do_input() // Get the state of the joypad axis/buttons if (joypad != NULL) { - // TODO: one different value of tolerance is needed for each direction - // This probably means the need for a tuning utility/window - int tolerance = (int)config.getValue("joytolerance", 100); + int lowerTolerance = (int)config.getValue("leftTolerance", -100); + int upperTolerance = (int)config.getValue("rightTolerance", 100); SDL_JoystickUpdate(); - if (SDL_JoystickGetAxis(joypad, 0) > tolerance) + int position = SDL_JoystickGetAxis(joypad, 0); + if (position >= upperTolerance) { joy[JOY_RIGHT] = true; } - if (SDL_JoystickGetAxis(joypad, 0) < -tolerance) + else if (position <= lowerTolerance) { joy[JOY_LEFT] = true; } - if (SDL_JoystickGetAxis(joypad, 1) < -tolerance) + lowerTolerance = (int)config.getValue("upTolerance", -100); + upperTolerance = (int)config.getValue("downTolerance", 100); + position = SDL_JoystickGetAxis(joypad, 1); + if (position <= lowerTolerance) { joy[JOY_UP] = true; } - if (SDL_JoystickGetAxis(joypad, 1) > tolerance) + else if (position >= upperTolerance) { joy[JOY_DOWN] = true; } diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index d76a0542..2114e635 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -26,6 +26,7 @@ #include <iostream> #include <sstream> +#include <guichan/widgets/container.hpp> #include <guichan/widgets/label.hpp> #include "button.h" @@ -34,6 +35,7 @@ #include "ok_dialog.h" #include "scrollarea.h" #include "slider.h" +#include "tabbedcontainer.h" #include "../configuration.h" #include "../graphics.h" @@ -50,6 +52,8 @@ extern Graphics *graphics; #include "skill.h" #include "status.h" +extern SDL_Joystick *joypad; + ModeListModel::ModeListModel() { SDL_Rect **modes; @@ -68,13 +72,13 @@ ModeListModel::ModeListModel() } else{ /* Print valid modes */ - /*logger->log("Available Modes"); + //logger->log("Available Modes"); for (int i = 0; modes[i]; ++i) { - logger->log(" %dx%d", modes[i]->w, modes[i]->h); + //logger->log(" %dx%d", modes[i]->w, modes[i]->h); std::stringstream mode; mode << (int)modes[i]->w << "x" << (int)modes[i]->h; videoModes.push_back(mode.str()); - }*/ + } } } @@ -94,9 +98,9 @@ std::string ModeListModel::getElementAt(int i) Setup::Setup(): - Window("Setup") + Window("Setup"), mCalibrating(false), leftTolerance(0), rightTolerance(0), + upTolerance(0), downTolerance(0) { - videoLabel = new gcn::Label("Video settings"); modeListModel = new ModeListModel(); modeList = new ListBox(modeListModel); modeList->setEnabled(false); @@ -109,12 +113,13 @@ Setup::Setup(): customCursorCheckBox = new CheckBox("Custom cursor"); alphaLabel = new gcn::Label("Gui opacity"); alphaSlider = new Slider(0.2, 1.0); - audioLabel = new gcn::Label("Audio settings"); soundCheckBox = new CheckBox("Sound", false); sfxSlider = new Slider(0, 128); musicSlider = new Slider(0, 128); sfxLabel = new gcn::Label("Sfx volume"); musicLabel = new gcn::Label("Music volume"); + calibrateLabel = new gcn::Label("Press the button to start calibration"); + calibrateButton = new Button("Calibrate"); applyButton = new Button("Apply"); cancelButton = new Button("Cancel"); resetWinsToDefault = new Button("Reset Windows"); @@ -127,33 +132,40 @@ Setup::Setup(): sfxSlider->setEventId("sfx"); musicSlider->setEventId("music"); customCursorCheckBox->setEventId("customcursor"); + calibrateButton->setEventId("calibrate"); // Set dimensions/positions - setContentSize(240, 246); + int width = 230; + int height = 185; + setContentSize(width, height); - videoLabel->setPosition(getWidth() - videoLabel->getWidth() - 5, 10); - scrollArea->setDimension(gcn::Rectangle(10, 30, 90, 50)); + scrollArea->setDimension(gcn::Rectangle(10, 10, 90, 50)); modeList->setDimension(gcn::Rectangle(0, 0, 60, 50)); - fsCheckBox->setPosition(110, 30); - openGLCheckBox->setPosition(110, 50); - customCursorCheckBox->setPosition(110, 70); - alphaSlider->setDimension(gcn::Rectangle(10, 100, 100, 10)); - alphaLabel->setPosition(20 + alphaSlider->getWidth(), 97); - - audioLabel->setPosition(getWidth() - videoLabel->getWidth() - 5, 120); - soundCheckBox->setPosition(10, 140); - sfxSlider->setDimension(gcn::Rectangle(10, 160, 100, 10)); - musicSlider->setDimension(gcn::Rectangle(10, 180, 100, 10)); - sfxLabel->setPosition(20 + sfxSlider->getWidth(), 157); - musicLabel->setPosition(20 + musicSlider->getWidth(), 177); - resetWinsToDefault->setPosition(20, 197); + fsCheckBox->setPosition(110, 10); + openGLCheckBox->setPosition(110, 30); + customCursorCheckBox->setPosition(110, 50); + alphaSlider->setDimension(gcn::Rectangle(10, 80, 100, 10)); + alphaLabel->setPosition(20 + alphaSlider->getWidth(), alphaSlider->getY()); + + soundCheckBox->setPosition(10, 10); + sfxSlider->setDimension(gcn::Rectangle(10, 30, 100, 10)); + musicSlider->setDimension(gcn::Rectangle(10, 50, 100, 10)); + sfxLabel->setPosition(20 + sfxSlider->getWidth(), 27); + musicLabel->setPosition(20 + musicSlider->getWidth(), 47); + + calibrateLabel->setPosition(5, 10); + calibrateButton->setPosition(10, 20 + calibrateLabel->getHeight()); + cancelButton->setPosition( - getWidth() - 10 - cancelButton->getWidth(), - getHeight() - 25 - cancelButton->getHeight()); + width - cancelButton->getWidth() - 5, + height - cancelButton->getHeight() - 5); applyButton->setPosition( - cancelButton->getX() - 10 - applyButton->getWidth(), - getHeight() - 25 - applyButton->getHeight()); - + cancelButton->getX() - applyButton->getWidth() - 5, + cancelButton->getY()); + resetWinsToDefault->setPosition( + applyButton->getX() - resetWinsToDefault->getWidth() - 5, + applyButton->getY()); + // Listen for actions applyButton->addActionListener(this); cancelButton->addActionListener(this); @@ -162,21 +174,38 @@ Setup::Setup(): sfxSlider->addActionListener(this); musicSlider->addActionListener(this); customCursorCheckBox->addActionListener(this); + calibrateButton->addActionListener(this); // Assemble dialog - add(videoLabel); - add(scrollArea); - add(fsCheckBox); - add(openGLCheckBox); - add(customCursorCheckBox); - add(audioLabel); - add(soundCheckBox); - add(alphaSlider); - add(alphaLabel); - add(sfxSlider); - add(musicSlider); - add(sfxLabel); - add(musicLabel); + gcn::Container *video = new gcn::Container(); + video->setOpaque(false); + video->add(scrollArea); + video->add(fsCheckBox); + video->add(openGLCheckBox); + video->add(customCursorCheckBox); + video->add(alphaSlider); + video->add(alphaLabel); + + gcn::Container *audio = new gcn::Container(); + audio->setOpaque(false); + audio->add(soundCheckBox); + audio->add(sfxSlider); + audio->add(musicSlider); + audio->add(sfxLabel); + audio->add(musicLabel); + + gcn::Container *input = new gcn::Container(); + input->setOpaque(false); + input->add(calibrateLabel); + input->add(calibrateButton); + + TabbedContainer *panel = new TabbedContainer(); + panel->setDimension(gcn::Rectangle(5, 5, 220, 130)); + panel->setOpaque(false); + panel->addTab(video, "Video"); + panel->addTab(audio, "Audio"); + panel->addTab(input, "Input"); + add(panel); add(resetWinsToDefault); add(applyButton); add(cancelButton); @@ -237,6 +266,28 @@ void Setup::action(const std::string &eventId) config.setValue("customcursor", customCursorCheckBox->isMarked() ? 1 : 0); } + else if (eventId == "calibrate" && joypad != NULL) + { + if (mCalibrating) + { + calibrateButton->setCaption("Calibrate"); + calibrateLabel->setCaption("Press the button to start calibration"); + config.setValue("leftTolerance", leftTolerance); + config.setValue("rightTolerance", rightTolerance); + config.setValue("upTolerance", upTolerance); + config.setValue("downTolerance", downTolerance); + } + else + { + calibrateButton->setCaption("Stop"); + calibrateLabel->setCaption("Rotate the stick"); + leftTolerance = 0; + rightTolerance = 0; + upTolerance = 0; + downTolerance = 0; + } + mCalibrating = !mCalibrating; + } else if (eventId == "apply") { setVisible(false); @@ -353,3 +404,31 @@ void Setup::action(const std::string &eventId) skillDialog->resetToDefaultSize(); } } + +void Setup::logic() +{ + Window::logic(); + if (mCalibrating) + { + SDL_JoystickUpdate(); + int position = SDL_JoystickGetAxis(joypad, 0); + if (position > rightTolerance) + { + rightTolerance = position; + } + else if (position < leftTolerance) + { + leftTolerance = position; + } + + position = SDL_JoystickGetAxis(joypad, 1); + if (position > downTolerance) + { + downTolerance = position; + } + else if (position < upTolerance) + { + upTolerance = position; + } + } +} diff --git a/src/gui/setup.h b/src/gui/setup.h index b76b9a55..0b62fee6 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -88,6 +88,8 @@ class Setup : public Window, public gcn::ActionListener */ void action(const std::string& eventId); + + void logic(); private: ModeListModel *modeListModel; @@ -95,15 +97,16 @@ class Setup : public Window, public gcn::ActionListener // Dialog widgets gcn::ListBox *modeList; gcn::ScrollArea *scrollArea; - gcn::Label *videoLabel, *audioLabel; gcn::Label *alphaLabel; gcn::Label *sfxLabel, *musicLabel; + gcn::Label *calibrateLabel; gcn::CheckBox *fsCheckBox; gcn::CheckBox *openGLCheckBox; gcn::CheckBox *soundCheckBox; gcn::CheckBox *customCursorCheckBox; gcn::Slider *alphaSlider; gcn::Slider *sfxSlider, *musicSlider; + gcn::Button *calibrateButton; gcn::Button *applyButton, *cancelButton; gcn::Button *resetWinsToDefault; @@ -114,6 +117,8 @@ class Setup : public Window, public gcn::ActionListener bool openGLEnabled; bool customCursorEnabled; bool soundEnabled; + bool mCalibrating; + int leftTolerance, rightTolerance, upTolerance, downTolerance; }; #endif diff --git a/src/main.cpp b/src/main.cpp index f0f885e7..f1f7cd4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -198,7 +198,6 @@ void init_engine() config.setValue("updatehost", "http://themanaworld.org/files"); config.setValue("customcursor", 1); config.setValue("homeDir", homeDir); - config.setValue("joytolerance", 100); // Checking if the configuration file exists... otherwise creates it with // default options ! |