Initial commit
This commit is contained in:
287
engines/ultima/nuvie/menus/asset_viewer_dialog.cpp
Normal file
287
engines/ultima/nuvie/menus/asset_viewer_dialog.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/asset_viewer_dialog.h"
|
||||
#include "ultima/nuvie/menus/video_dialog.h"
|
||||
#include "ultima/nuvie/menus/audio_dialog.h"
|
||||
#include "ultima/nuvie/menus/gameplay_dialog.h"
|
||||
#include "ultima/nuvie/menus/input_dialog.h"
|
||||
#include "ultima/nuvie/menus/cheats_dialog.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/core/events.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
#include "ultima/nuvie/nuvie.h"
|
||||
#include "ultima/nuvie/files/u6_shape.h"
|
||||
#include "ultima/nuvie/files/u6_bmp.h"
|
||||
|
||||
#include "common/keyboard.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int AVD_WIDTH = 320;
|
||||
static const int AVD_HEIGHT = 200;
|
||||
|
||||
AssetViewerDialog::AssetViewerDialog(CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - AVD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - AVD_HEIGHT) / 2,
|
||||
AVD_WIDTH, AVD_HEIGHT, 100, 100, 100, GUI_DIALOG_UNMOVABLE),
|
||||
callback_object(callback), _viewMode(TileViewMode) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool AssetViewerDialog::init() {
|
||||
_curIdx = 0;
|
||||
_shapeIdx = 0;
|
||||
_curShape = nullptr;
|
||||
|
||||
GUI *gui = GUI::get_gui();
|
||||
GUI_Font *font = gui->get_font();
|
||||
TileManager *tileman = Game::get_game()->get_tile_manager();
|
||||
|
||||
_maxIdx = tileman->get_numtiles();
|
||||
|
||||
Common::String title = Common::String::format("Tile %d / %d", _curIdx, _maxIdx);
|
||||
_titleTxt = new GUI_Text(10, 10, 0, 0, 0, title.c_str(), font);
|
||||
AddWidget(_titleTxt);
|
||||
_infoTxt = new GUI_Text(10, 25, 0, 0, 0, "info text about the asset will appear here", font);
|
||||
AddWidget(_infoTxt);
|
||||
updateInfoTxt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AssetViewerDialog::~AssetViewerDialog() {
|
||||
}
|
||||
|
||||
GUI_status AssetViewerDialog::close_dialog() {
|
||||
if (_curShape)
|
||||
delete _curShape;
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(GAMEMENUDIALOG_CB_DELETE, nullptr, this);
|
||||
GUI::get_gui()->unlock_input();
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
void AssetViewerDialog::Display(bool full_redraw) {
|
||||
GUI_Dialog::Display(full_redraw);
|
||||
|
||||
if (_viewMode == TileViewMode) {
|
||||
TileManager *tileman = Game::get_game()->get_tile_manager();
|
||||
Screen *gameScreen = Game::get_game()->get_screen();
|
||||
const Tile *tile = tileman->get_tile(_curIdx);
|
||||
|
||||
if (tile) {
|
||||
gameScreen->blit(offset_x + 100, offset_y + 100, tile->data, 8, 16, 16, 16, tile->transparent);
|
||||
if (tile->dbl_width) {
|
||||
const Tile *left = tileman->get_tile(_curIdx - 1);
|
||||
gameScreen->blit(offset_x + 100 - 16, offset_y + 100, left->data, 8, 16, 16, 16, left->transparent);
|
||||
}
|
||||
if (tile->dbl_height && !tile->dbl_width) {
|
||||
const Tile *top = tileman->get_tile(_curIdx - 1);
|
||||
gameScreen->blit(offset_x + 100, offset_y + 100 - 16, top->data, 8, 16, 16, 16, top->transparent);
|
||||
} else if (tile->dbl_height) {
|
||||
// dbl width and double-height
|
||||
const Tile *topleft = tileman->get_tile(_curIdx - 3);
|
||||
gameScreen->blit(offset_x + 100 - 16, offset_y + 100 - 16, topleft->data, 8, 16, 16, 16, topleft->transparent);
|
||||
const Tile *top = tileman->get_tile(_curIdx - 2);
|
||||
gameScreen->blit(offset_x + 100, offset_y + 100 - 16, top->data, 8, 16, 16, 16, top->transparent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert(_viewMode == ScreenViewMode && _curShape);
|
||||
if (_curShape->get_data()) {
|
||||
uint16 w = 0;
|
||||
uint16 h = 0;
|
||||
_curShape->get_size(&w, &h);
|
||||
screen->blit(offset_x + 10, offset_y + 40, _curShape->get_data(), 8, w, h, w, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssetViewerDialog::updateInfoTxt() {
|
||||
if (_viewMode == TileViewMode) {
|
||||
TileManager *tileman = Game::get_game()->get_tile_manager();
|
||||
const Tile *tile = tileman->get_tile(_curIdx);
|
||||
|
||||
Common::String title = Common::String::format("Tile %d / %d", _curIdx, _maxIdx);
|
||||
_titleTxt->setText(title.c_str());
|
||||
|
||||
if (!tile) {
|
||||
_infoTxt->setText("((null tile))");
|
||||
} else {
|
||||
Common::String txt;
|
||||
if (tile->damages)
|
||||
txt += "Dmg ";
|
||||
if (tile->transparent)
|
||||
txt += "Trnsp ";
|
||||
if (tile->boundary)
|
||||
txt += "Bndry ";
|
||||
if (tile->dbl_height)
|
||||
txt += "DblH ";
|
||||
if (tile->dbl_width)
|
||||
txt += "DblW ";
|
||||
if (tile->passable)
|
||||
txt += "Pass ";
|
||||
if (tile->water)
|
||||
txt += "Water ";
|
||||
if (tile->toptile)
|
||||
txt += "Top ";
|
||||
|
||||
_infoTxt->setText(txt.c_str());
|
||||
}
|
||||
} else {
|
||||
Common::String title = Common::String::format("Screen %d,%d / %d", _shapeIdx, _curIdx, _maxIdx);
|
||||
_titleTxt->setText(title.c_str());
|
||||
if (_curShape && _curShape->get_data()) {
|
||||
uint16 w = 0;
|
||||
uint16 h = 0;
|
||||
_curShape->get_size(&w, &h);
|
||||
if (w == 0 || h == 0) {
|
||||
_infoTxt->setText("(empty shape)");
|
||||
} else {
|
||||
uint16 x = 0;
|
||||
uint16 y = 0;
|
||||
_curShape->get_hot_point(&x, &y);
|
||||
Common::String info = Common::String::format("sz (%d,%d) hot (%d,%d)", w, h, x, y);
|
||||
_infoTxt->setText(info.c_str());
|
||||
}
|
||||
} else {
|
||||
_infoTxt->setText("(null shape)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssetViewerDialog::updateShape() {
|
||||
if (_viewMode == ScreenViewMode) {
|
||||
if (_curShape)
|
||||
delete _curShape;
|
||||
if (Game::get_game()->get_game_type() == NUVIE_GAME_U6) {
|
||||
_curShape = new U6Bmp();
|
||||
_curShape->load(_screenFile);
|
||||
} else {
|
||||
_curShape = new U6Shape();
|
||||
_curShape->load_from_lzc(_screenFile, _shapeIdx, _curIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI_status AssetViewerDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
nuvie_game_t game_type = Game::get_game()->get_game_type();
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NEXT_PARTY_MEMBER_KEY:
|
||||
_shapeIdx++;
|
||||
if (_shapeIdx > 2)
|
||||
_shapeIdx = 0;
|
||||
updateShape();
|
||||
updateInfoTxt();
|
||||
break;
|
||||
case PREVIOUS_PARTY_MEMBER_KEY:
|
||||
_shapeIdx--;
|
||||
if (_shapeIdx < 0)
|
||||
_shapeIdx = 2;
|
||||
updateShape();
|
||||
updateInfoTxt();
|
||||
break;
|
||||
case NORTH_KEY:
|
||||
if (key.flags & Common::KBD_SHIFT)
|
||||
_curIdx -= 10;
|
||||
else
|
||||
_curIdx--;
|
||||
if (_curIdx < 0)
|
||||
_curIdx = _maxIdx + _curIdx;
|
||||
|
||||
updateShape();
|
||||
updateInfoTxt();
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
if (key.flags & Common::KBD_SHIFT)
|
||||
_curIdx += 10;
|
||||
else
|
||||
_curIdx++;
|
||||
if (_curIdx >= _maxIdx)
|
||||
_curIdx -= _maxIdx;
|
||||
|
||||
updateShape();
|
||||
updateInfoTxt();
|
||||
break;
|
||||
case WEST_KEY:
|
||||
case EAST_KEY:
|
||||
_curIdx = 0;
|
||||
if (_viewMode == TileViewMode) {
|
||||
_viewMode = ScreenViewMode;
|
||||
_screenFile = "";
|
||||
if (game_type == NUVIE_GAME_MD) {
|
||||
config_get_path(config, "mdscreen.lzc", _screenFile);
|
||||
_maxIdx = 4;
|
||||
} else if (game_type == NUVIE_GAME_SE) {
|
||||
config_get_path(config, "screen.lzc", _screenFile);
|
||||
_maxIdx = 4;
|
||||
} else { // U6
|
||||
config_get_path(config, "paper.bmp", _screenFile);
|
||||
_maxIdx = 1;
|
||||
}
|
||||
updateShape();
|
||||
} else {
|
||||
delete _curShape;
|
||||
_curShape = nullptr;
|
||||
_viewMode = TileViewMode;
|
||||
_maxIdx = Game::get_game()->get_tile_manager()->get_numtiles();
|
||||
}
|
||||
updateInfoTxt();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status AssetViewerDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
GUI *gui = GUI::get_gui();
|
||||
|
||||
if (caller == this) {
|
||||
close_dialog();
|
||||
} else {
|
||||
gui->lock_input(this);
|
||||
return GUI_PASS;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
71
engines/ultima/nuvie/menus/asset_viewer_dialog.h
Normal file
71
engines/ultima/nuvie/menus/asset_viewer_dialog.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_ASSET_VIEWER_DIALOG_H
|
||||
#define NUVIE_MENUS_ASSET_VIEWER_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
#define GAMEMENUDIALOG_CB_DELETE 3
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_Text;
|
||||
class U6Shape;
|
||||
|
||||
class AssetViewerDialog : public GUI_Dialog {
|
||||
enum ViewMode {
|
||||
TileViewMode,
|
||||
ScreenViewMode,
|
||||
};
|
||||
|
||||
protected:
|
||||
CallBack *callback_object;
|
||||
GUI_Text *_titleTxt, *_infoTxt;
|
||||
int _curIdx, _maxIdx;
|
||||
int _shapeIdx;
|
||||
ViewMode _viewMode;
|
||||
U6Shape *_curShape;
|
||||
Common::Path _screenFile;
|
||||
public:
|
||||
AssetViewerDialog(CallBack *callback);
|
||||
~AssetViewerDialog() override;
|
||||
|
||||
void Display(bool full_redraw) override;
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
|
||||
private:
|
||||
void updateInfoTxt();
|
||||
void updateShape();
|
||||
bool init();
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
286
engines/ultima/nuvie/menus/audio_dialog.cpp
Normal file
286
engines/ultima/nuvie/menus/audio_dialog.cpp
Normal file
@@ -0,0 +1,286 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_text_toggle_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/audio_dialog.h"
|
||||
#include "ultima/nuvie/sound/sound_manager.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
#include "ultima/nuvie/core/party.h"
|
||||
#include "ultima/nuvie/core/converse.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/nuvie.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int AD_WIDTH = 292;
|
||||
static const int AD_HEIGHT = 166;
|
||||
|
||||
AudioDialog::AudioDialog(GUI_CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - AD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - AD_HEIGHT) / 2,
|
||||
AD_WIDTH, AD_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool AudioDialog::init() {
|
||||
int height = 12;
|
||||
int colX[] = { 213, 243 };
|
||||
int textX[] = { 9, 19, 29 };
|
||||
int buttonY = 9;
|
||||
uint8 textY = 11;
|
||||
uint8 row_h = 13;
|
||||
b_index_num = -1;
|
||||
last_index = 0;
|
||||
|
||||
GUI_Widget *widget;
|
||||
GUI_Font *font = GUI::get_gui()->get_font();
|
||||
|
||||
widget = new GUI_Text(textX[0], textY, 0, 0, 0, "Audio:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[1], textY += row_h, 0, 0, 0, "Enable music:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Music volume:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Combat changes music:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Vehicle changes music:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Conversations stop music:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Stop music on group change:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[1], textY += row_h, 0, 0, 0, "Enable sfx:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(textX[2], textY += row_h, 0, 0, 0, "Sfx volume:", font);
|
||||
AddWidget(widget);
|
||||
bool use_speech_b = (Game::get_game()->get_game_type() == NUVIE_GAME_U6 && has_fmtowns_support(Game::get_game()->get_config()));
|
||||
if (use_speech_b) {
|
||||
widget = new GUI_Text(textX[1], textY += row_h, 0, 0, 0, "Enable speech:", font);
|
||||
AddWidget(widget);
|
||||
}
|
||||
char musicBuff[5], sfxBuff[5];
|
||||
int sfxVol_selection, musicVol_selection, num_of_sfxVol, num_of_musicVol;
|
||||
SoundManager *sm = Game::get_game()->get_sound_manager();
|
||||
const char *const enabled_text[] = { "Disabled", "Enabled" };
|
||||
const char *const yes_no_text[] = { "no", "yes" };
|
||||
|
||||
uint8 music_percent = round(sm->get_music_volume() / 2.55); // round needed for 10%, 30%, etc.
|
||||
Common::sprintf_s(musicBuff, "%u%%", music_percent);
|
||||
const char *const musicVol_text[] = { "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", musicBuff };
|
||||
|
||||
if (music_percent % 10 == 0) {
|
||||
num_of_musicVol = 11;
|
||||
musicVol_selection = music_percent / 10;
|
||||
} else {
|
||||
num_of_musicVol = 12;
|
||||
musicVol_selection = 11;
|
||||
}
|
||||
|
||||
uint8 sfx_percent = round(sm->get_sfx_volume() / 2.55); // round needed for 10%, 30%, etc.
|
||||
Common::sprintf_s(sfxBuff, "%u%%", sfx_percent);
|
||||
const char *const sfxVol_text[] = { "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", sfxBuff };
|
||||
|
||||
if (sfx_percent % 10 == 0) {
|
||||
num_of_sfxVol = 11;
|
||||
sfxVol_selection = sfx_percent / 10;
|
||||
} else {
|
||||
num_of_sfxVol = 12;
|
||||
sfxVol_selection = 11;
|
||||
}
|
||||
|
||||
audio_button = new GUI_TextToggleButton(this, colX[0], buttonY, 70, height, enabled_text, 2, sm->is_audio_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(audio_button);
|
||||
button_index[last_index] = audio_button;
|
||||
|
||||
music_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, sm->is_music_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(music_button);
|
||||
button_index[last_index += 1] = music_button;
|
||||
|
||||
musicVol_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, musicVol_text, num_of_musicVol, musicVol_selection, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(musicVol_button);
|
||||
button_index[last_index += 1] = musicVol_button;
|
||||
|
||||
Party *party = Game::get_game()->get_party();
|
||||
combat_b = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, party->combat_changes_music, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(combat_b);
|
||||
button_index[last_index += 1] = combat_b;
|
||||
|
||||
vehicle_b = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, party->vehicles_change_music, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(vehicle_b);
|
||||
button_index[last_index += 1] = vehicle_b;
|
||||
|
||||
bool stop_converse = Game::get_game()->get_converse()->conversations_stop_music;
|
||||
converse_b = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, stop_converse, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(converse_b);
|
||||
button_index[last_index += 1] = converse_b;
|
||||
|
||||
group_b = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, sm->stop_music_on_group_change, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(group_b);
|
||||
button_index[last_index += 1] = group_b;
|
||||
|
||||
sfx_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, sm->is_sfx_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(sfx_button);
|
||||
button_index[last_index += 1] = sfx_button;
|
||||
|
||||
sfxVol_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, sfxVol_text, num_of_sfxVol, sfxVol_selection, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(sfxVol_button);
|
||||
button_index[last_index += 1] = sfxVol_button;
|
||||
|
||||
if (use_speech_b) {
|
||||
speech_b = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, 40, height, yes_no_text, 2, sm->is_speech_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(speech_b);
|
||||
button_index[last_index += 1] = speech_b;
|
||||
} else
|
||||
speech_b = nullptr;
|
||||
cancel_button = new GUI_Button(this, 80, AD_HEIGHT - 20, 54, height, "Cancel", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cancel_button);
|
||||
button_index[last_index += 1] = cancel_button;
|
||||
|
||||
save_button = new GUI_Button(this, 151, AD_HEIGHT - 20, 60, height, "Save", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index += 1] = save_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AudioDialog::~AudioDialog() {
|
||||
}
|
||||
|
||||
GUI_status AudioDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(0, this, this);
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status AudioDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
case WEST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
case EAST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status AudioDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
if (caller == cancel_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
SoundManager *sm = Game::get_game()->get_sound_manager();
|
||||
|
||||
int music_selection = musicVol_button->GetSelection();
|
||||
if (music_selection != 11) {
|
||||
uint8 musicVol = music_selection * 25.5;
|
||||
sm->set_music_volume(musicVol);
|
||||
if (sm->get_m_pCurrentSong() != nullptr)
|
||||
sm->get_m_pCurrentSong()->SetVolume(musicVol);
|
||||
config->set("config/music_volume", musicVol);
|
||||
}
|
||||
|
||||
int sfx_selection = sfxVol_button->GetSelection();
|
||||
if (sfx_selection != 11) {
|
||||
uint8 sfxVol = sfx_selection * 25.5;
|
||||
sm->set_sfx_volume(sfxVol);
|
||||
// probably need to update sfx volume if we have background sfx implemented
|
||||
config->set("config/sfx_volume", sfxVol);
|
||||
}
|
||||
|
||||
if ((bool)music_button->GetSelection() != sm->is_music_enabled())
|
||||
sm->set_music_enabled(music_button->GetSelection());
|
||||
config->set("config/music_mute", !music_button->GetSelection());
|
||||
if ((bool)sfx_button->GetSelection() != sm->is_sfx_enabled())
|
||||
sm->set_sfx_enabled(sfx_button->GetSelection());
|
||||
|
||||
Party *party = Game::get_game()->get_party();
|
||||
party->combat_changes_music = combat_b->GetSelection();
|
||||
config->set("config/audio/combat_changes_music", combat_b->GetSelection() ? "yes" : "no");
|
||||
|
||||
party->vehicles_change_music = vehicle_b->GetSelection();
|
||||
config->set("config/audio/vehicles_change_music", vehicle_b->GetSelection() ? "yes" : "no");
|
||||
|
||||
Game::get_game()->get_converse()->conversations_stop_music = converse_b->GetSelection();
|
||||
config->set("config/audio/conversations_stop_music", converse_b->GetSelection() ? "yes" : "no");
|
||||
|
||||
sm->stop_music_on_group_change = group_b->GetSelection();
|
||||
config->set("config/audio/stop_music_on_group_change", group_b->GetSelection() ? "yes" : "no");
|
||||
|
||||
config->set("config/sfx_mute", !sfx_button->GetSelection());
|
||||
if ((bool)audio_button->GetSelection() != sm->is_audio_enabled())
|
||||
sm->set_audio_enabled(audio_button->GetSelection());
|
||||
config->set("config/mute", !audio_button->GetSelection());
|
||||
|
||||
if (speech_b) {
|
||||
bool speech_enabled = speech_b->GetSelection() ? true : false;
|
||||
config->set("config/speech_mute", !speech_b->GetSelection());
|
||||
if (speech_enabled != sm->is_speech_enabled())
|
||||
sm->set_speech_enabled(speech_enabled);
|
||||
}
|
||||
config->write();
|
||||
return close_dialog();
|
||||
}
|
||||
|
||||
return GUI_PASS;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
59
engines/ultima/nuvie/menus/audio_dialog.h
Normal file
59
engines/ultima/nuvie/menus/audio_dialog.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_AUDIO_DIALOG_H
|
||||
#define NUVIE_MENUS_AUDIO_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_TextToggleButton;
|
||||
|
||||
class AudioDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
GUI_CallBack *callback_object;
|
||||
GUI_Button *save_button, *cancel_button;
|
||||
GUI_TextToggleButton *audio_button, *music_button, *musicType_button, *musicVol_button,
|
||||
*sfx_button, *sfxVol_button, *sfxType_button, *combat_b, *group_b,
|
||||
*vehicle_b, *converse_b, *speech_b;
|
||||
GUI_Button *button_index[14]; // add to here when you add a button. Keep buttons in order by height
|
||||
|
||||
public:
|
||||
AudioDialog(GUI_CallBack *callback);
|
||||
~AudioDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
217
engines/ultima/nuvie/menus/cheats_dialog.cpp
Normal file
217
engines/ultima/nuvie/menus/cheats_dialog.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_text_toggle_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/cheats_dialog.h"
|
||||
#include "ultima/nuvie/core/egg_manager.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/core/converse.h"
|
||||
#include "ultima/nuvie/core/obj_manager.h"
|
||||
#include "ultima/nuvie/gui/widgets/map_window.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int CD_WIDTH = 212;
|
||||
static const int CD_HEIGHT = 101;
|
||||
|
||||
CheatsDialog::CheatsDialog(GUI_CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - CD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - CD_HEIGHT) / 2,
|
||||
CD_WIDTH, CD_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool CheatsDialog::init() {
|
||||
int textY[] = { 11, 24, 37, 50, 63 };
|
||||
int buttonY[] = { 9, 22, 35, 48, 61, 80 };
|
||||
int colX[] = { 9, 163 };
|
||||
int height = 12;
|
||||
b_index_num = -1;
|
||||
last_index = 0;
|
||||
GUI_Widget *widget;
|
||||
GUI *gui = GUI::get_gui();
|
||||
|
||||
widget = new GUI_Text(colX[0], textY[0], 0, 0, 0, "Cheats:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY[1], 0, 0, 0, "Show eggs:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY[2], 0, 0, 0, "Enable hackmove:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY[3], 0, 0, 0, "Anyone will join:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY[4], 0, 0, 0, "Minimum brightness:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
|
||||
bool party_all_the_time;
|
||||
Game *game = Game::get_game();
|
||||
Configuration *config = game->get_config();
|
||||
config->value("config/cheats/party_all_the_time", party_all_the_time);
|
||||
const char *const enabled_text[] = { "Disabled", "Enabled" };
|
||||
const char *const yesno_text[] = { "no", "yes" };
|
||||
char buff[4];
|
||||
int brightness_selection;
|
||||
int num_of_brightness = 8;
|
||||
uint8 min_brightness = game->get_map_window()->get_min_brightness();
|
||||
|
||||
if (min_brightness == 255) {
|
||||
brightness_selection = 7;
|
||||
} else if (min_brightness % 20 == 0 && min_brightness <= 120) {
|
||||
brightness_selection = min_brightness / 20;
|
||||
} else {
|
||||
num_of_brightness = 9;
|
||||
brightness_selection = 8; // manually edited setting or old 128
|
||||
Common::sprintf_s(buff, "%d", min_brightness);
|
||||
}
|
||||
const char *const brightness_text[] = { "0", "20", "40", "60", "80", "100", "120", "255", buff };
|
||||
|
||||
cheat_button = new GUI_TextToggleButton(this, colX[1] - 30, buttonY[0], 70, height, enabled_text, 2, game->are_cheats_enabled(), gui->get_font(), BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(cheat_button);
|
||||
button_index[last_index] = cheat_button;
|
||||
|
||||
egg_button = new GUI_TextToggleButton(this, colX[1], buttonY[1], 40, height, yesno_text, 2, game->get_obj_manager()->is_showing_eggs(), gui->get_font(), BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(egg_button);
|
||||
button_index[last_index += 1] = egg_button;
|
||||
|
||||
hackmove_button = new GUI_TextToggleButton(this, colX[1], buttonY[2], 40, height, yesno_text, 2, game->using_hackmove(), gui->get_font(), BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(hackmove_button);
|
||||
button_index[last_index += 1] = hackmove_button;
|
||||
|
||||
party_button = new GUI_TextToggleButton(this, colX[1], buttonY[3], 40, height, yesno_text, 2, party_all_the_time, gui->get_font(), BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(party_button);
|
||||
button_index[last_index += 1] = party_button;
|
||||
|
||||
brightness_button = new GUI_TextToggleButton(this, colX[1], buttonY[4], 40, height, brightness_text, num_of_brightness, brightness_selection, gui->get_font(), BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(brightness_button);
|
||||
button_index[last_index += 1] = brightness_button;
|
||||
|
||||
cancel_button = new GUI_Button(this, 50, buttonY[5], 54, height, "Cancel", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cancel_button);
|
||||
button_index[last_index += 1] = cancel_button;
|
||||
|
||||
save_button = new GUI_Button(this, 121, buttonY[5], 40, height, "Save", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index += 1] = save_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CheatsDialog::~CheatsDialog() {
|
||||
}
|
||||
|
||||
GUI_status CheatsDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(0, this, this); // I don't think this does anything atm
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status CheatsDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
case WEST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
case EAST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status CheatsDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
if (caller == cancel_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
Game *game = Game::get_game();
|
||||
Configuration *config = game->get_config();
|
||||
|
||||
Std::string key = config_get_game_key(config);
|
||||
key.append("/show_eggs");
|
||||
config->set(key, egg_button->GetSelection() ? "yes" : "no");
|
||||
game->get_obj_manager()->set_show_eggs(egg_button->GetSelection());
|
||||
game->get_egg_manager()->set_egg_visibility(cheat_button->GetSelection() ? egg_button->GetSelection() : false);
|
||||
|
||||
game->set_cheats_enabled(cheat_button->GetSelection());
|
||||
config->set("config/cheats/enabled", cheat_button->GetSelection() ? "yes" : "no");
|
||||
game->set_hackmove(hackmove_button->GetSelection());
|
||||
config->set("config/cheats/enable_hackmove", hackmove_button->GetSelection() ? "yes" : "no");
|
||||
game->get_converse()->set_party_all_the_time(party_button->GetSelection());
|
||||
config->set("config/cheats/party_all_the_time", party_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
int brightness = brightness_button->GetSelection();
|
||||
if (brightness < 8) {
|
||||
int min_brightness;
|
||||
if (brightness == 7)
|
||||
min_brightness = 255;
|
||||
else
|
||||
min_brightness = brightness * 20;
|
||||
config->set("config/cheats/min_brightness", min_brightness);
|
||||
game->get_map_window()->set_min_brightness(min_brightness);
|
||||
game->get_map_window()->updateAmbience();
|
||||
}
|
||||
|
||||
config->write();
|
||||
return close_dialog();
|
||||
}
|
||||
|
||||
return GUI_PASS;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
57
engines/ultima/nuvie/menus/cheats_dialog.h
Normal file
57
engines/ultima/nuvie/menus/cheats_dialog.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_CHEATS_DIALOG_H
|
||||
#define NUVIE_MENUS_CHEATS_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_TextToggleButton;
|
||||
|
||||
class CheatsDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
GUI_CallBack *callback_object;
|
||||
GUI_Button *save_button, *cancel_button;
|
||||
GUI_TextToggleButton *brightness_button, *cheat_button, *egg_button, *hackmove_button, *party_button;
|
||||
GUI_Button *button_index[7]; // add to here when you add a button. Keep buttons in order by height
|
||||
|
||||
public:
|
||||
CheatsDialog(GUI_CallBack *callback);
|
||||
~CheatsDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
193
engines/ultima/nuvie/menus/game_menu_dialog.cpp
Normal file
193
engines/ultima/nuvie/menus/game_menu_dialog.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/game_menu_dialog.h"
|
||||
#include "ultima/nuvie/menus/video_dialog.h"
|
||||
#include "ultima/nuvie/menus/audio_dialog.h"
|
||||
#include "ultima/nuvie/menus/gameplay_dialog.h"
|
||||
#include "ultima/nuvie/menus/input_dialog.h"
|
||||
#include "ultima/nuvie/menus/cheats_dialog.h"
|
||||
#include "ultima/nuvie/core/events.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
#include "ultima/nuvie/nuvie.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int GMD_WIDTH = 150;
|
||||
static const int GMD_HEIGHT = 135;
|
||||
|
||||
GameMenuDialog::GameMenuDialog(CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - GMD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - GMD_HEIGHT) / 2,
|
||||
GMD_WIDTH, GMD_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool GameMenuDialog::init() {
|
||||
int width = 132;
|
||||
int height = 12;
|
||||
int buttonX = 9;
|
||||
int buttonY = 9;
|
||||
int row_h = 13;
|
||||
b_index_num = -1;
|
||||
last_index = 0;
|
||||
GUI *gui = GUI::get_gui();
|
||||
|
||||
save_button = new GUI_Button(this, buttonX, buttonY, width, height, "Save Game", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index] = save_button;
|
||||
load_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Load Game", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(load_button);
|
||||
button_index[++last_index] = load_button;
|
||||
video_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Video Options", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(video_button);
|
||||
button_index[++last_index] = video_button;
|
||||
audio_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Audio Options", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(audio_button);
|
||||
button_index[++last_index] = audio_button;
|
||||
input_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Input Options", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(input_button);
|
||||
button_index[++last_index] = input_button;
|
||||
gameplay_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Gameplay Options", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(gameplay_button);
|
||||
button_index[++last_index] = gameplay_button;
|
||||
cheats_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Cheats", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cheats_button);
|
||||
button_index[++last_index] = cheats_button;
|
||||
continue_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Back to Game", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(continue_button);
|
||||
button_index[++last_index] = continue_button;
|
||||
quit_button = new GUI_Button(this, buttonX, buttonY += row_h, width, height, "Quit", gui->get_font(), BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(quit_button);
|
||||
button_index[++last_index] = quit_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GameMenuDialog::~GameMenuDialog() {
|
||||
}
|
||||
|
||||
GUI_status GameMenuDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(GAMEMENUDIALOG_CB_DELETE, nullptr, this);
|
||||
GUI::get_gui()->unlock_input();
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status GameMenuDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status GameMenuDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
GUI *gui = GUI::get_gui();
|
||||
|
||||
if (caller == this) {
|
||||
close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
close_dialog();
|
||||
// Redraw so the dialog does not show in the save thumbnail
|
||||
gui->force_full_redraw();
|
||||
gui->Display();
|
||||
gui->get_screen()->update();
|
||||
g_engine->saveGameDialog();
|
||||
} else if (caller == load_button) {
|
||||
g_engine->loadGameDialog();
|
||||
close_dialog();
|
||||
} else if (caller == video_button) {
|
||||
GUI_Widget *video_dialog;
|
||||
video_dialog = new VideoDialog(this);
|
||||
GUI::get_gui()->AddWidget(video_dialog);
|
||||
gui->lock_input(video_dialog);
|
||||
} else if (caller == audio_button) {
|
||||
GUI_Widget *audio_dialog;
|
||||
audio_dialog = new AudioDialog(this);
|
||||
GUI::get_gui()->AddWidget(audio_dialog);
|
||||
gui->lock_input(audio_dialog);
|
||||
} else if (caller == input_button) {
|
||||
GUI_Widget *input_dialog;
|
||||
input_dialog = new InputDialog(this);
|
||||
GUI::get_gui()->AddWidget(input_dialog);
|
||||
gui->lock_input(input_dialog);
|
||||
} else if (caller == gameplay_button) {
|
||||
GUI_Widget *gameplay_dialog;
|
||||
gameplay_dialog = new GameplayDialog(this);
|
||||
GUI::get_gui()->AddWidget(gameplay_dialog);
|
||||
gui->lock_input(gameplay_dialog);
|
||||
} else if (caller == cheats_button) {
|
||||
GUI_Widget *cheats_dialog;
|
||||
cheats_dialog = new CheatsDialog(this);
|
||||
GUI::get_gui()->AddWidget(cheats_dialog);
|
||||
gui->lock_input(cheats_dialog);
|
||||
} else if (caller == continue_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == quit_button) {
|
||||
Game::get_game()->get_event()->quitDialog();
|
||||
} else {
|
||||
gui->lock_input(this);
|
||||
return GUI_PASS;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
58
engines/ultima/nuvie/menus/game_menu_dialog.h
Normal file
58
engines/ultima/nuvie/menus/game_menu_dialog.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_GAME_MENU_DIALOG_H
|
||||
#define NUVIE_MENUS_GAME_MENU_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
#define GAMEMENUDIALOG_CB_DELETE 3
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
|
||||
class GameMenuDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
CallBack *callback_object;
|
||||
GUI_Button *load_button, *save_button, *video_button, *audio_button, *input_button,
|
||||
*gameplay_button, *cheats_button, *continue_button, *quit_button;
|
||||
GUI_Button *button_index[9]; // add to here when you add a button. Keep buttons in order by height
|
||||
public:
|
||||
GameMenuDialog(CallBack *callback);
|
||||
~GameMenuDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
296
engines/ultima/nuvie/menus/gameplay_dialog.cpp
Normal file
296
engines/ultima/nuvie/menus/gameplay_dialog.cpp
Normal file
@@ -0,0 +1,296 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_text_toggle_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/gameplay_dialog.h"
|
||||
#include "ultima/nuvie/core/party.h"
|
||||
#include "ultima/nuvie/script/script.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/core/converse.h"
|
||||
#include "ultima/nuvie/gui/widgets/converse_gump.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
#include "ultima/nuvie/gui/widgets/background.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int GD_WIDTH = 274;
|
||||
static const int GD_HEIGHT = 179;
|
||||
|
||||
GameplayDialog::GameplayDialog(GUI_CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - GD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - GD_HEIGHT) / 2,
|
||||
GD_WIDTH, GD_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
int get_selected_game_index(const Std::string configvalue) {
|
||||
if (string_i_compare(configvalue, "menuselect")) {
|
||||
return 0;
|
||||
} else if (string_i_compare(configvalue, "ultima6")) {
|
||||
return 1;
|
||||
} else if (string_i_compare(configvalue, "savage")) {
|
||||
return 2;
|
||||
} else if (string_i_compare(configvalue, "martian")) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 1; //default to U6
|
||||
}
|
||||
|
||||
bool GameplayDialog::init() {
|
||||
int height = 12;
|
||||
int yesno_width = 32;
|
||||
const int selected_game_width = 120;
|
||||
int colX[] = { 9, 40, 233 };
|
||||
int buttonY = 9;
|
||||
uint8 textY = 11;
|
||||
uint8 row_h = 13;
|
||||
b_index_num = -1;
|
||||
last_index = 0;
|
||||
|
||||
GUI_Widget *widget;
|
||||
GUI *gui = GUI::get_gui();
|
||||
GUI_Font *font = gui->get_font();
|
||||
Game *game = Game::get_game();
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
const char *const yesno_text[] = { "no", "yes" };
|
||||
const char *const formation_text[] = { "standard", "column", "row", "delta" };
|
||||
const char *const selected_game_text[] = {"Menu Select", "Ultima VI", "Savage Empire", "Martian Dreams"};
|
||||
const char *const converse_style_text[] = {"Default", "U7 Style", "WOU Style"};
|
||||
|
||||
Std::string selected_game;
|
||||
config->value("config/loadgame", selected_game, "");
|
||||
|
||||
bool is_u6 = (game->get_game_type() == NUVIE_GAME_U6);
|
||||
bool show_stealing, skip_intro, show_console, use_original_cursor, solid_bg;
|
||||
Std::string key = config_get_game_key(config);
|
||||
config->value(key + "/skip_intro", skip_intro, false);
|
||||
config->value("config/general/show_console", show_console, false);
|
||||
config->value("config/general/enable_cursors", use_original_cursor, false);
|
||||
// party formation
|
||||
widget = new GUI_Text(colX[0], textY, 0, 0, 0, "Party formation:", font);
|
||||
AddWidget(widget);
|
||||
formation_button = new GUI_TextToggleButton(this, 197, buttonY, 68, height, formation_text, 4, game->get_party()->get_formation(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(formation_button);
|
||||
button_index[last_index] = formation_button;
|
||||
if (is_u6) {
|
||||
// show stealing
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Look shows private property:", font);
|
||||
AddWidget(widget);
|
||||
config->value("config/ultima6/show_stealing", show_stealing, false);
|
||||
stealing_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, show_stealing, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(stealing_button);
|
||||
button_index[last_index += 1] = stealing_button;
|
||||
} else {
|
||||
stealing_button = nullptr;
|
||||
}
|
||||
if (!Game::get_game()->is_new_style()) {
|
||||
// Use text gump
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Use text gump:", font);
|
||||
AddWidget(widget);
|
||||
text_gump_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, game->is_using_text_gumps(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(text_gump_button);
|
||||
button_index[last_index += 1] = text_gump_button;
|
||||
// use converse gump
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Converse gump:", font);
|
||||
AddWidget(widget);
|
||||
converse_gump_button = new GUI_TextToggleButton(this, 187, buttonY += row_h, 78, height, converse_style_text, 3, get_converse_gump_type_from_config(config), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(converse_gump_button);
|
||||
old_converse_gump_type = game->get_converse_gump_type();
|
||||
button_index[last_index += 1] = converse_gump_button;
|
||||
} else {
|
||||
text_gump_button = nullptr;
|
||||
converse_gump_button = nullptr;
|
||||
}
|
||||
if (!game->is_forcing_solid_converse_bg()) {
|
||||
// converse solid bg
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Converse gump has solid bg:", font);
|
||||
AddWidget(widget);
|
||||
config->value(key + "/converse_solid_bg", solid_bg, false); // need to check cfg since converse_gump may be nullptr
|
||||
converse_solid_bg_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, solid_bg, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(converse_solid_bg_button);
|
||||
button_index[last_index += 1] = converse_solid_bg_button;
|
||||
} else
|
||||
converse_solid_bg_button = nullptr;
|
||||
|
||||
|
||||
// following require restart
|
||||
widget = new GUI_Text(colX[0], textY += row_h * 2, 0, 0, 0, "The following require a restart:", font);
|
||||
AddWidget(widget);
|
||||
// game select
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Startup game:", font);
|
||||
AddWidget(widget);
|
||||
startup_game_button = new GUI_TextToggleButton(this, 145, buttonY += row_h * 3, selected_game_width, height, selected_game_text, 4, get_selected_game_index(selected_game), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(startup_game_button);
|
||||
button_index[last_index += 1] = startup_game_button;
|
||||
// skip intro
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Skip intro:", font);
|
||||
AddWidget(widget);
|
||||
skip_intro_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, skip_intro, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(skip_intro_button);
|
||||
button_index[last_index += 1] = skip_intro_button;
|
||||
// show console
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Show console:", font);
|
||||
AddWidget(widget);
|
||||
show_console_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, show_console, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(show_console_button);
|
||||
button_index[last_index += 1] = show_console_button;
|
||||
// original cursor
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Use original cursors:", font);
|
||||
AddWidget(widget);
|
||||
cursor_button = new GUI_TextToggleButton(this, colX[2], buttonY += row_h, yesno_width, height, yesno_text, 2, use_original_cursor, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(cursor_button);
|
||||
button_index[last_index += 1] = cursor_button;
|
||||
|
||||
cancel_button = new GUI_Button(this, 77, GD_HEIGHT - 20, 54, height, "Cancel", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cancel_button);
|
||||
button_index[last_index += 1] = cancel_button;
|
||||
save_button = new GUI_Button(this, 158, GD_HEIGHT - 20, 40, height, "Save", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index += 1] = save_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GameplayDialog::~GameplayDialog() {
|
||||
}
|
||||
|
||||
GUI_status GameplayDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(0, this, this);
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status GameplayDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
case WEST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
case EAST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
const char *get_selected_game_config_string(int selected_index) {
|
||||
const char *config_strings[] = {"menuselect", "ultima6", "savage", "martian" };
|
||||
|
||||
if (selected_index < 0 || selected_index > 3) {
|
||||
return config_strings[1];
|
||||
}
|
||||
|
||||
return config_strings[selected_index];
|
||||
}
|
||||
|
||||
|
||||
const char *get_converse_gump_config_string(int selected_index) {
|
||||
const char *config_strings[] = {"default", "u7style", "wou" };
|
||||
|
||||
if (selected_index < 0 || selected_index >= 3) {
|
||||
return config_strings[0];
|
||||
}
|
||||
|
||||
return config_strings[selected_index];
|
||||
}
|
||||
|
||||
GUI_status GameplayDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
if (caller == cancel_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
Game *game = Game::get_game();
|
||||
Configuration *config = game->get_config();
|
||||
Std::string key = config_get_game_key(config);
|
||||
|
||||
game->get_party()->set_formation(formation_button->GetSelection());
|
||||
config->set("config/general/party_formation", formation_button->GetSelection() ? "yes" : "no");
|
||||
if (game->get_game_type() == NUVIE_GAME_U6) {
|
||||
game->get_script()->call_set_g_show_stealing(stealing_button->GetSelection());
|
||||
config->set("config/ultima6/show_stealing", stealing_button->GetSelection() ? "yes" : "no");
|
||||
}
|
||||
if (!Game::get_game()->is_new_style()) {
|
||||
game->set_using_text_gumps(text_gump_button->GetSelection());
|
||||
config->set("config/general/use_text_gumps", text_gump_button->GetSelection() ? "yes" : "no");
|
||||
ConverseGumpType converse_gump_type = static_cast<ConverseGumpType>(converse_gump_button->GetSelection());
|
||||
if (converse_gump_type != old_converse_gump_type) {
|
||||
config->set("config/general/converse_gump", get_converse_gump_config_string(converse_gump_type));
|
||||
game->set_converse_gump_type(converse_gump_type);
|
||||
}
|
||||
}
|
||||
if (converse_solid_bg_button) {
|
||||
if (game->get_converse_gump())
|
||||
game->get_converse_gump()->set_solid_bg(converse_solid_bg_button->GetSelection());
|
||||
config->set(key + "/converse_solid_bg", converse_solid_bg_button->GetSelection() ? "yes" : "no");
|
||||
}
|
||||
config->set("config/loadgame", get_selected_game_config_string(startup_game_button->GetSelection()));
|
||||
config->set(key + "/skip_intro", skip_intro_button->GetSelection() ? "yes" : "no"); // need restart
|
||||
config->set("config/general/show_console", show_console_button->GetSelection() ? "yes" : "no"); // need restart
|
||||
config->set("config/general/enable_cursors", cursor_button->GetSelection() ? "yes" : "no"); // need restart
|
||||
|
||||
config->write();
|
||||
close_dialog();
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
return GUI_PASS;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
61
engines/ultima/nuvie/menus/gameplay_dialog.h
Normal file
61
engines/ultima/nuvie/menus/gameplay_dialog.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_GAMEPLAY_DIALOG_H
|
||||
#define NUVIE_MENUS_GAMEPLAY_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_TextToggleButton;
|
||||
|
||||
class GameplayDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
ConverseGumpType old_converse_gump_type;
|
||||
GUI_CallBack *callback_object;
|
||||
GUI_Button *save_button, *cancel_button;
|
||||
GUI_TextToggleButton *formation_button, *stealing_button, *text_gump_button,
|
||||
*converse_gump_button, *converse_solid_bg_button,
|
||||
*startup_game_button, *skip_intro_button, *show_console_button,
|
||||
*cursor_button;
|
||||
GUI_Button *button_index[11]; // add to here when you add a button. Keep buttons in order by height
|
||||
|
||||
public:
|
||||
GameplayDialog(GUI_CallBack *callback);
|
||||
~GameplayDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
280
engines/ultima/nuvie/menus/input_dialog.cpp
Normal file
280
engines/ultima/nuvie/menus/input_dialog.cpp
Normal file
@@ -0,0 +1,280 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_text_toggle_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/input_dialog.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
#include "ultima/nuvie/core/events.h"
|
||||
#include "ultima/nuvie/gui/widgets/map_window.h"
|
||||
#include "ultima/nuvie/views/party_view.h"
|
||||
#include "ultima/nuvie/views/view_manager.h"
|
||||
#include "ultima/nuvie/gui/widgets/command_bar_new_ui.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int ID_WIDTH = 280;
|
||||
static const int ID_HEIGHT = 166;
|
||||
|
||||
InputDialog::InputDialog(GUI_CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - ID_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - ID_HEIGHT) / 2,
|
||||
ID_WIDTH, ID_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool InputDialog::init() {
|
||||
uint8 textY = 11;
|
||||
uint8 buttonY = 9;
|
||||
int colX[] = { 9, 239 };
|
||||
int height = 12;
|
||||
uint8 row_h = 13;
|
||||
int yesno_width = 32;
|
||||
b_index_num = -1;
|
||||
last_index = 0;
|
||||
GUI_Widget *widget;
|
||||
GUI *gui = GUI::get_gui();
|
||||
GUI_Font *font = gui->get_font();
|
||||
Game *game = Game::get_game();
|
||||
MapWindow *map_window = game->get_map_window();
|
||||
|
||||
widget = new GUI_Text(colX[0], textY, 0, 0, 0, "Interface:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Dragging enabled:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Direction selects target:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Look on left_click:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Walk with left button:", font);
|
||||
AddWidget(widget);
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Enable doubleclick:", font);
|
||||
AddWidget(widget);
|
||||
if (game->get_game_type() == NUVIE_GAME_U6) {
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Allow free balloon movement:", font);
|
||||
AddWidget(widget);
|
||||
}
|
||||
if (!game->is_new_style()) {
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Doubleclick opens containers:", font);
|
||||
AddWidget(widget);
|
||||
}
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Use new command bar:", font);
|
||||
AddWidget(widget);
|
||||
if (!game->is_new_style()) {
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Party view targeting:", font);
|
||||
AddWidget(widget);
|
||||
}
|
||||
|
||||
Configuration *config = game->get_config();
|
||||
int interface;
|
||||
Std::string interface_str;
|
||||
config->value("config/input/interface", interface_str, "normal"); // get cfg variable because hackmove changes InterfaceType
|
||||
if (interface_str == "ignore_block")
|
||||
interface = 2;
|
||||
else if (interface_str == "fullscreen")
|
||||
interface = 1;
|
||||
else // normal
|
||||
interface = 0;
|
||||
|
||||
const char *const yesno_text[] = { "no", "yes" };
|
||||
const char *const interface_text[] = { "Normal", "U7 like", "ignores obstacles" };
|
||||
|
||||
interface_button = new GUI_TextToggleButton(this, 129, buttonY, 142, height, interface_text, 3, interface, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(interface_button);
|
||||
button_index[last_index] = interface_button;
|
||||
|
||||
dragging_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, game->is_dragging_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(dragging_button);
|
||||
button_index[last_index += 1] = dragging_button;
|
||||
|
||||
direction_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, game->get_event()->is_direction_selecting_targets(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(direction_button);
|
||||
button_index[last_index += 1] = direction_button;
|
||||
|
||||
look_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, map_window->will_look_on_left_click(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(look_button);
|
||||
button_index[last_index += 1] = look_button;
|
||||
|
||||
walk_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, map_window->will_walk_with_left_button(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(walk_button);
|
||||
button_index[last_index += 1] = walk_button;
|
||||
|
||||
doubleclick_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, map_window->is_doubleclick_enabled(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(doubleclick_button);
|
||||
button_index[last_index += 1] = doubleclick_button;
|
||||
|
||||
if (game->get_game_type() == NUVIE_GAME_U6) {
|
||||
balloon_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, game->has_free_balloon_movement(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(balloon_button);
|
||||
button_index[last_index += 1] = balloon_button;
|
||||
} else
|
||||
balloon_button = nullptr;
|
||||
if (!Game::get_game()->is_new_style()) {
|
||||
open_container_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, game->doubleclick_opens_containers(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(open_container_button);
|
||||
button_index[last_index += 1] = open_container_button;
|
||||
}
|
||||
command_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, game->get_new_command_bar() != nullptr, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(command_button);
|
||||
button_index[last_index += 1] = command_button;
|
||||
|
||||
if (!Game::get_game()->is_new_style()) {
|
||||
bool party_view_targeting;
|
||||
config->value("config/input/party_view_targeting", party_view_targeting, false);
|
||||
party_targeting_button = new GUI_TextToggleButton(this, colX[1], buttonY += row_h, yesno_width, height, yesno_text, 2, party_view_targeting, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(party_targeting_button);
|
||||
button_index[last_index += 1] = party_targeting_button;
|
||||
} else
|
||||
open_container_button = party_targeting_button = nullptr;
|
||||
cancel_button = new GUI_Button(this, 83, ID_HEIGHT - 20, 54, height, "Cancel", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cancel_button);
|
||||
button_index[last_index += 1] = cancel_button;
|
||||
|
||||
save_button = new GUI_Button(this, 154, ID_HEIGHT - 20, 40, height, "Save", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index += 1] = save_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
InputDialog::~InputDialog() {
|
||||
}
|
||||
|
||||
GUI_status InputDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(0, this, this);
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status InputDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
case WEST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
case EAST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status InputDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
if (caller == cancel_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
Game *game = Game::get_game();
|
||||
MapWindow *map_window = game->get_map_window();
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
|
||||
Std::string interface_str;
|
||||
if (interface_button->GetSelection() == 2)
|
||||
interface_str = "ignore_block";
|
||||
else if (interface_button->GetSelection() == 1)
|
||||
interface_str = "fullscreen";
|
||||
else // 0
|
||||
interface_str = "normal";
|
||||
config->set("config/input/interface", interface_str);
|
||||
map_window->set_interface(); // must come after you set cfg
|
||||
|
||||
game->set_dragging_enabled(dragging_button->GetSelection());
|
||||
config->set("config/input/enabled_dragging", dragging_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
game->get_event()->set_direction_selects_target(direction_button->GetSelection());
|
||||
config->set("config/input/direction_selects_target", direction_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
map_window->set_look_on_left_click(look_button->GetSelection());
|
||||
config->set("config/input/look_on_left_click", look_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
map_window->set_walk_with_left_button(walk_button->GetSelection());
|
||||
config->set("config/input/walk_with_left_button", walk_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
map_window->set_enable_doubleclick(doubleclick_button->GetSelection());
|
||||
config->set("config/input/enable_doubleclick", doubleclick_button->GetSelection() ? "yes" : "no");
|
||||
|
||||
map_window->set_use_left_clicks(); // allow or disallow left clicks - Must come after look_on_left_click and enable_doubleclick
|
||||
|
||||
if (game->get_game_type() == NUVIE_GAME_U6) {
|
||||
game->set_free_balloon_movement(balloon_button->GetSelection() == 1);
|
||||
config->set(config_get_game_key(config) + "/free_balloon_movement", balloon_button->GetSelection() ? "yes" : "no");
|
||||
}
|
||||
if (open_container_button) {
|
||||
game->set_doubleclick_opens_containers(open_container_button->GetSelection());
|
||||
config->set("config/input/doubleclick_opens_containers", open_container_button->GetSelection() ? "yes" : "no");
|
||||
}
|
||||
if (command_button->GetSelection())
|
||||
game->init_new_command_bar();
|
||||
else
|
||||
game->delete_new_command_bar();
|
||||
config->set("config/input/new_command_bar", command_button->GetSelection() ? "yes" : "no");
|
||||
if (party_targeting_button) {
|
||||
game->get_view_manager()->get_party_view()->set_party_view_targeting(party_targeting_button->GetSelection());
|
||||
config->set("config/input/party_view_targeting", party_targeting_button->GetSelection() ? "yes" : "no");
|
||||
}
|
||||
|
||||
config->write();
|
||||
close_dialog();
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
return GUI_PASS;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
60
engines/ultima/nuvie/menus/input_dialog.h
Normal file
60
engines/ultima/nuvie/menus/input_dialog.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_INPUT_DIALOG_H
|
||||
#define NUVIE_MENUS_INPUT_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_TextToggleButton;
|
||||
|
||||
class InputDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
GUI_CallBack *callback_object;
|
||||
GUI_Button *save_button, *cancel_button;
|
||||
GUI_TextToggleButton *command_button, *direction_button, *doubleclick_button,
|
||||
*dragging_button, *interface_button, *look_button,
|
||||
*open_container_button, *party_targeting_button, *walk_button,
|
||||
*balloon_button;
|
||||
GUI_Button *button_index[12]; // add to here when you add a button. Keep buttons in order by height
|
||||
|
||||
public:
|
||||
InputDialog(GUI_CallBack *callback);
|
||||
~InputDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
315
engines/ultima/nuvie/menus/video_dialog.cpp
Normal file
315
engines/ultima/nuvie/menus/video_dialog.cpp
Normal file
@@ -0,0 +1,315 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ultima/nuvie/core/nuvie_defs.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/gui_types.h"
|
||||
#include "ultima/nuvie/gui/gui_button.h"
|
||||
#include "ultima/nuvie/gui/gui_text.h"
|
||||
#include "ultima/nuvie/gui/gui_text_toggle_button.h"
|
||||
#include "ultima/nuvie/gui/gui_callback.h"
|
||||
#include "ultima/nuvie/gui/gui_area.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/screen/dither.h"
|
||||
#include "ultima/nuvie/screen/screen.h"
|
||||
#include "ultima/nuvie/gui/widgets/map_window.h"
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
#include "ultima/nuvie/menus/video_dialog.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
#include "ultima/nuvie/views/view_manager.h"
|
||||
#include "ultima/nuvie/views/inventory_view.h"
|
||||
#include "ultima/nuvie/keybinding/keys.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
static const int VD_WIDTH = 311;
|
||||
static const int VD_HEIGHT = 171; // add or subtract 13 if you add/remove a row
|
||||
|
||||
VideoDialog::VideoDialog(GUI_CallBack *callback)
|
||||
: GUI_Dialog(Game::get_game()->get_game_x_offset() + (Game::get_game()->get_game_width() - VD_WIDTH) / 2,
|
||||
Game::get_game()->get_game_y_offset() + (Game::get_game()->get_game_height() - VD_HEIGHT) / 2,
|
||||
VD_WIDTH, VD_HEIGHT, 244, 216, 131, GUI_DIALOG_UNMOVABLE), callback_object(callback),
|
||||
non_square_pixels_button(nullptr) {
|
||||
init();
|
||||
grab_focus();
|
||||
}
|
||||
|
||||
bool VideoDialog::init() {
|
||||
const int colX[] = { 9, 29, 63, 232, 270};
|
||||
int height = 12;
|
||||
int yesno_width = 32;
|
||||
int buttonY = 9;
|
||||
uint8 textY = 11;
|
||||
uint8 row_h = 13;
|
||||
last_index = 0;
|
||||
b_index_num = -1;
|
||||
GUI_Widget *widget;
|
||||
GUI *gui = GUI::get_gui();
|
||||
GUI_Font *font = gui->get_font();
|
||||
Game *game = Game::get_game();
|
||||
Screen *scr = game->get_screen();
|
||||
const char *const yesno_text[] = { "no", "yes" };
|
||||
only2x_button = nullptr;
|
||||
|
||||
// fullscreen_toggle
|
||||
widget = new GUI_Text(colX[0], textY, 0, 0, 0, "Fullscreen:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
|
||||
fullscreen_button = new GUI_TextToggleButton(this, colX[4], buttonY, yesno_width, height, yesno_text, 2, scr->is_fullscreen(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(fullscreen_button);
|
||||
button_index[last_index] = fullscreen_button;
|
||||
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Non-square pixels:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
non_square_pixels_button = new GUI_TextToggleButton(this, colX[4], buttonY += row_h, yesno_width, height, yesno_text, 2, scr->is_non_square_pixels(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(non_square_pixels_button);
|
||||
button_index[last_index += 1] = non_square_pixels_button;
|
||||
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
|
||||
// show roofs
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Show roofs:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
roof_button = new GUI_TextToggleButton(this, colX[4], buttonY += row_h, yesno_width, height, yesno_text, 2, game->is_roof_mode(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(roof_button);
|
||||
button_index[(last_index += 1)] = roof_button;
|
||||
|
||||
// use_new_dolls
|
||||
if (game->is_new_style()) {
|
||||
doll_button = nullptr;
|
||||
old_use_new_dolls = true;
|
||||
} else {
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Use new actor dolls:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
bool use_new_dolls;
|
||||
config->value(config_get_game_key(config) + "/use_new_dolls", use_new_dolls, false);
|
||||
old_use_new_dolls = use_new_dolls;
|
||||
doll_button = new GUI_TextToggleButton(this, colX[4], buttonY += row_h, yesno_width, height, yesno_text, 2, use_new_dolls, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(doll_button);
|
||||
button_index[last_index += 1] = doll_button;
|
||||
}
|
||||
|
||||
// tile_lighting_b
|
||||
widget = new GUI_Text(colX[0], textY += row_h, 0, 0, 0, "Use lighting data from map tiles:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
old_use_tile_lighting = game->get_map_window()->using_map_tile_lighting;
|
||||
tile_lighting_b = new GUI_TextToggleButton(this, colX[4], buttonY += row_h, yesno_width, height, yesno_text, 2, old_use_tile_lighting, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(tile_lighting_b);
|
||||
button_index[last_index += 1] = tile_lighting_b;
|
||||
|
||||
// needs restart text
|
||||
widget = new GUI_Text(colX[0], textY += row_h * 2, 0, 0, 0, "The following require a restart:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
|
||||
// lighting (needs reset)
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Lighting mode:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
const char *const lighting_text[] = { "none", "smooth", "original" };
|
||||
lighting_button = new GUI_TextToggleButton(this, colX[3], buttonY += row_h * 3, 70, height, lighting_text, ARRAYSIZE(lighting_text), scr->get_old_lighting_style(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(lighting_button);
|
||||
button_index[last_index += 1] = lighting_button;
|
||||
|
||||
// sprites (needs reset)
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Use custom actor tiles:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
const char *const sprite_text[] = { "no", "yes", "default" };
|
||||
Std::string custom_tile_str;
|
||||
int custom_tiles;
|
||||
config->value(config_get_game_key(config) + "/custom_actor_tiles", custom_tile_str, "default");
|
||||
if (custom_tile_str == "default")
|
||||
custom_tiles = 2;
|
||||
else
|
||||
custom_tiles = custom_tile_str == "yes" ? 1 : 0;
|
||||
sprites_b = new GUI_TextToggleButton(this, colX[3], buttonY += row_h, 70, height, sprite_text, ARRAYSIZE(sprite_text), custom_tiles, font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(sprites_b);
|
||||
button_index[last_index += 1] = sprites_b;
|
||||
|
||||
// game_style (needs reset)
|
||||
const char *game_style_text[] = {
|
||||
"original style",
|
||||
"new style",
|
||||
"original+",
|
||||
"original+ full map"};
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Game style:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
game_style_button = new GUI_TextToggleButton(this, colX[3] - 84, buttonY += row_h, 154, height, game_style_text, ARRAYSIZE(game_style_text), game->get_game_style(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(game_style_button);
|
||||
button_index[last_index += 1] = game_style_button;
|
||||
|
||||
// dithering (needs reset)
|
||||
widget = new GUI_Text(colX[1], textY += row_h, 0, 0, 0, "Old video graphics:", gui->get_font());
|
||||
AddWidget(widget);
|
||||
const char *const dither_text[] = { "no", "CGA", "EGA" };
|
||||
dither_button = new GUI_TextToggleButton(this, colX[4], buttonY += row_h, yesno_width, height, dither_text, ARRAYSIZE(dither_text), game->get_dither()->get_mode(), font, BUTTON_TEXTALIGN_CENTER, this, 0);
|
||||
AddWidget(dither_button);
|
||||
button_index[last_index += 1] = dither_button;
|
||||
|
||||
// cancel/save buttons
|
||||
cancel_button = new GUI_Button(this, 95, VD_HEIGHT - 20, 54, height, "Cancel", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(cancel_button);
|
||||
button_index[last_index += 1] = cancel_button;
|
||||
save_button = new GUI_Button(this, 170, VD_HEIGHT - 20, 40, height, "Save", font, BUTTON_TEXTALIGN_CENTER, 0, this, 0);
|
||||
AddWidget(save_button);
|
||||
button_index[last_index += 1] = save_button;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
VideoDialog::~VideoDialog() {
|
||||
}
|
||||
|
||||
GUI_status VideoDialog::close_dialog() {
|
||||
Delete(); // mark dialog as deleted. it will be freed by the GUI object
|
||||
callback_object->callback(0, this, this);
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status VideoDialog::KeyDown(const Common::KeyState &key) {
|
||||
KeyBinder *keybinder = Game::get_game()->get_keybinder();
|
||||
ActionType a = keybinder->get_ActionType(key);
|
||||
|
||||
switch (keybinder->GetActionKeyType(a)) {
|
||||
case NORTH_KEY:
|
||||
case WEST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num <= 0)
|
||||
b_index_num = last_index;
|
||||
else
|
||||
b_index_num = b_index_num - 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case SOUTH_KEY:
|
||||
case EAST_KEY:
|
||||
if (b_index_num != -1)
|
||||
button_index[b_index_num]->set_highlighted(false);
|
||||
|
||||
if (b_index_num == last_index)
|
||||
b_index_num = 0;
|
||||
else
|
||||
b_index_num += 1;
|
||||
button_index[b_index_num]->set_highlighted(true);
|
||||
break;
|
||||
case DO_ACTION_KEY:
|
||||
if (b_index_num != -1) return button_index[b_index_num]->Activate_button();
|
||||
break;
|
||||
case CANCEL_ACTION_KEY:
|
||||
return close_dialog();
|
||||
default:
|
||||
keybinder->handle_always_available_keys(a);
|
||||
break;
|
||||
}
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
GUI_status VideoDialog::callback(uint16 msg, GUI_CallBack *caller, void *data) {
|
||||
if (caller == cancel_button) {
|
||||
return close_dialog();
|
||||
} else if (caller == save_button) {
|
||||
Game *game = Game::get_game();
|
||||
Screen *scr = Game::get_game()->get_screen();
|
||||
Configuration *config = Game::get_game()->get_config();
|
||||
|
||||
bool fullscreen = fullscreen_button ? fullscreen_button->GetSelection() : scr->is_fullscreen();
|
||||
if (fullscreen != scr->is_fullscreen())
|
||||
scr->toggle_fullscreen();
|
||||
bool non_square_pixels = non_square_pixels_button ? (bool)non_square_pixels_button->GetSelection() : false;
|
||||
scr->set_non_square_pixels(non_square_pixels);
|
||||
|
||||
// fullscreen
|
||||
config->set("config/fullscreen", fullscreen ? "yes" : "no");
|
||||
game->get_screen()->set_fullscreen(fullscreen);
|
||||
|
||||
// non-square pixels
|
||||
config->set("config/video/non_square_pixels", non_square_pixels ? "yes" : "no");
|
||||
// roof mode
|
||||
bool roof_mode = roof_button->GetSelection();
|
||||
game->set_roof_mode(roof_mode);
|
||||
game->get_map_window()->set_roof_mode(roof_mode);
|
||||
game->get_game_map()->set_roof_mode(roof_mode);
|
||||
config->set(config_get_game_key(config) + "/roof_mode", roof_mode ? "yes" : "no");
|
||||
// use_new_dolls
|
||||
if (doll_button && old_use_new_dolls != (doll_button->GetSelection() ? 1 : 0)) {
|
||||
config->set(config_get_game_key(config) + "/use_new_dolls", doll_button->GetSelection() ? "yes" : "no");
|
||||
ViewManager *vm = game->get_view_manager();
|
||||
InventoryView *iv = vm->get_inventory_view();
|
||||
if (vm->get_current_view() == iv) // showing a doll so need to reset
|
||||
iv->set_party_member(iv->get_party_member_num());
|
||||
}
|
||||
|
||||
// tile_lighting_b
|
||||
if (old_use_tile_lighting != (bool)tile_lighting_b->GetSelection()) {
|
||||
config->set(config_get_game_key(config) + "/map_tile_lighting", tile_lighting_b->GetSelection() ? "yes" : "no");
|
||||
game->get_map_window()->using_map_tile_lighting = tile_lighting_b->GetSelection() == 1;
|
||||
game->get_map_window()->updateAmbience();
|
||||
}
|
||||
|
||||
// lighting
|
||||
const char *lighting_char;
|
||||
int lighting = lighting_button->GetSelection();
|
||||
if (lighting == 0)
|
||||
lighting_char = "none";
|
||||
else if (lighting == 1)
|
||||
lighting_char = "smooth";
|
||||
else
|
||||
lighting_char = "original";
|
||||
config->set("config/general/lighting", lighting_char);
|
||||
|
||||
// sprites
|
||||
const char *sprite_char;
|
||||
if (sprites_b->GetSelection() == 2)
|
||||
sprite_char = "default";
|
||||
else
|
||||
sprite_char = sprites_b->GetSelection() ? "yes" : "no";
|
||||
config->set(config_get_game_key(config) + "/custom_actor_tiles", sprite_char);
|
||||
|
||||
// game_style
|
||||
const char *game_style_text[] = {
|
||||
"original",
|
||||
"new",
|
||||
"original+",
|
||||
"original+_full_map"};
|
||||
config->set("config/video/game_style", game_style_text[game_style_button->GetSelection()]);
|
||||
|
||||
// dither
|
||||
const char *dither_char;
|
||||
uint8 dither = dither_button->GetSelection();
|
||||
if (dither == 0)
|
||||
dither_char = "none";
|
||||
else if (dither == 1)
|
||||
dither_char = "cga";
|
||||
else
|
||||
dither_char = "ega";
|
||||
config->set("config/general/dither_mode", dither_char);
|
||||
|
||||
config->write();
|
||||
close_dialog();
|
||||
return GUI_YUM;
|
||||
}
|
||||
|
||||
return GUI_PASS;
|
||||
}
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
58
engines/ultima/nuvie/menus/video_dialog.h
Normal file
58
engines/ultima/nuvie/menus/video_dialog.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_MENUS_VIDEO_DIALOG_H
|
||||
#define NUVIE_MENUS_VIDEO_DIALOG_H
|
||||
|
||||
#include "ultima/nuvie/gui/gui_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class GUI;
|
||||
class GUI_CallBack;
|
||||
class GUI_Button;
|
||||
class GUI_TextToggleButton;
|
||||
|
||||
class VideoDialog : public GUI_Dialog {
|
||||
protected:
|
||||
uint8 last_index;
|
||||
sint8 b_index_num;
|
||||
bool old_use_new_dolls, old_use_tile_lighting;
|
||||
GUI_CallBack *callback_object;
|
||||
GUI_Button *save_button, *cancel_button, *only2x_button;
|
||||
GUI_TextToggleButton *fullscreen_button, *non_square_pixels_button, *roof_button, *lighting_button, *dither_button,
|
||||
*game_style_button, *doll_button, *tile_lighting_b, *sprites_b;
|
||||
GUI_Button *button_index[11]; // add to here when you add a button. Keep buttons in order by height
|
||||
public:
|
||||
VideoDialog(GUI_CallBack *callback);
|
||||
~VideoDialog() override;
|
||||
bool init();
|
||||
|
||||
GUI_status close_dialog();
|
||||
GUI_status KeyDown(const Common::KeyState &key) override;
|
||||
GUI_status callback(uint16 msg, GUI_CallBack *caller, void *data) override;
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user