Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged big parts of the GmaeModeMedia class into a GlobalMedia one.

This will load the most common files used in the different game modes
instead of loading/unloading them when changing the game mode.

I also made a few misc code cleanups while doing it.

I didn't completely removed the GameModeMedia classes as certain
ressources there were still specific to their game mode, such as
the battle background, music and so on.

I also simplified the way status effect icons are queried, avoid
the use of an extra map for it.

I didn't touch the menu mode yet, as I'm not sure of what will change
for now. I did that before playing with the menu mode as it will
much easier to query status effect icons now :)

But this is IMHO sufficient to close #121.
  • Loading branch information...
commit a6e1faa2c987fefa5055d14dca2ab4d78f4900d8 1 parent 9076e6a
Yohann Ferreira authored
View
18 dat/effects/status.lua
@@ -8,7 +8,6 @@
-- Each status effect implementation requires the following data to be defined.
-- {name} - The name of the status effect as it will be shown to the player
-- {default_duration} - The default duration that the effect lasts, in milliseconds
--- {icon_index} - A numeric index to the row of images where the icons for this effect
-- {opposite_effect} - The status which acts as an opposite status to this one
-- {Apply} - A function executed when the status effect is applied to the target
-- {Update} - A function executed periodically while the status is still in effect
@@ -47,7 +46,6 @@ end
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_RAISE] = {
name = hoa_system.Translate("Raise Strength"),
default_duration = 30000,
- icon_index = 0,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_LOWER,
Apply = function(effect)
@@ -93,7 +91,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_LOWER] = {
name = hoa_system.Translate("Lower Strength"),
default_duration = 30000,
- icon_index = 1,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_RAISE,
Apply = function(effect)
@@ -139,7 +136,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_RAISE] = {
name = hoa_system.Translate("Raise Vigor"),
default_duration = 30000,
- icon_index = 2,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_LOWER,
Apply = function(effect)
@@ -185,7 +181,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_LOWER] = {
name = hoa_system.Translate("Lower Vigor"),
default_duration = 30000,
- icon_index = 3,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_RAISE,
Apply = function(effect)
@@ -231,7 +226,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_RAISE] = {
name = hoa_system.Translate("Raise Fortitude"),
default_duration = 30000,
- icon_index = 4,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_LOWER,
Apply = function(effect)
@@ -277,7 +271,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_LOWER] = {
name = hoa_system.Translate("Lower Fortitude"),
default_duration = 30000,
- icon_index = 5,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_RAISE,
Apply = function(effect)
@@ -323,7 +316,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_RAISE] = {
name = hoa_system.Translate("Raise Protection"),
default_duration = 30000,
- icon_index = 6,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_LOWER,
Apply = function(effect)
@@ -369,7 +361,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_LOWER] = {
name = hoa_system.Translate("Lower Protection"),
default_duration = 30000,
- icon_index = 7,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_RAISE,
Apply = function(effect)
@@ -415,7 +406,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE] = {
name = hoa_system.Translate("Raise Agility"),
default_duration = 30000,
- icon_index = 8,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_LOWER,
Apply = function(effect)
@@ -463,7 +453,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_LOWER] = {
name = hoa_system.Translate("Lower Agility"),
default_duration = 30000,
- icon_index = 9,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE,
Apply = function(effect)
@@ -511,7 +500,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_RAISE] = {
name = hoa_system.Translate("Raise Evasion"),
default_duration = 30000,
- icon_index = 10,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_LOWER,
Apply = function(effect)
@@ -560,7 +548,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_RAISE] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_LOWER] = {
name = hoa_system.Translate("Lower Evasion"),
default_duration = 30000,
- icon_index = 11,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_RAISE,
Apply = function(effect)
@@ -606,7 +593,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_LOWER] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_HP_REGEN] = {
name = hoa_system.Translate("Regenerate HP"),
default_duration = 30000,
- icon_index = 12,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_HP_DRAIN,
Apply = function(effect)
@@ -625,7 +611,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_HP_REGEN] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_HP_DRAIN] = {
name = hoa_system.Translate("Drain HP"),
default_duration = 30000,
- icon_index = 13,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_HP_REGEN,
Apply = function(effect)
@@ -644,7 +629,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_HP_DRAIN] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_SP_REGEN] = {
name = hoa_system.Translate("Regenerate SP"),
default_duration = 30000,
- icon_index = 14,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_SP_DRAIN,
Apply = function(effect)
@@ -663,7 +647,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_SP_REGEN] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_SP_DRAIN] = {
name = hoa_system.Translate("Drain SP"),
default_duration = 30000,
- icon_index = 15,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_SP_REGEN,
Apply = function(effect)
@@ -682,7 +665,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_SP_DRAIN] = {
status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PARALYSIS] = {
name = hoa_system.Translate("Paralysis"),
default_duration = 10000,
- icon_index = 16,
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_INVALID,
Apply = function(effect)
View
BIN  img/icons/object_category_icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 src/common/global/global.cpp
@@ -96,6 +96,14 @@ GameGlobal::~GameGlobal()
_CloseGlobalScripts();
} // GameGlobal::~GameGlobal()
+bool GameGlobal::SingletonInitialize()
+{
+ // Init the media files.
+ _global_media.Initialize();
+
+ return _LoadGlobalScripts();
+}
+
void GameGlobal::_CloseGlobalScripts() {
// Close all persistent script files
_global_script.CloseFile();
View
13 src/common/global/global.h
@@ -335,8 +335,7 @@ class GameGlobal : public hoa_utils::Singleton<GameGlobal>
public:
~GameGlobal();
- bool SingletonInitialize()
- { return _LoadGlobalScripts(); }
+ bool SingletonInitialize();
//! Reloads the persistent scripts. Used when changing the language for instance.
bool ReloadGlobalScripts()
@@ -948,6 +947,13 @@ class GameGlobal : public hoa_utils::Singleton<GameGlobal>
else return 0;
}
+ //! \brief Gives access to global media files.
+ //! Note: The reference is passed non const to be able to give modifiable references
+ //! and pointers.
+ GlobalMedia& Media() {
+ return _global_media;
+ }
+
private:
GameGlobal();
@@ -1114,6 +1120,9 @@ class GameGlobal : public hoa_utils::Singleton<GameGlobal>
//! \brief a map of the quest string ids to their info
std::map<std::string, QuestLogInfo> _quest_log_info;
+ // ----- Global media files
+ //! \brief member storing all the common media files.
+ GlobalMedia _global_media;
// ----- Private methods
View
191 src/common/global/global_utils.cpp
@@ -18,6 +18,7 @@
#include "global.h"
#include "engine/system.h"
+#include "engine/audio/audio_descriptor.h"
using namespace hoa_utils;
using namespace hoa_system;
@@ -192,4 +193,194 @@ bool DecrementIntensity(GLOBAL_INTENSITY &intensity, uint8 amount)
return true;
}
+// GlobalMedia functions
+
+void GlobalMedia::Initialize()
+{
+ // Load common images
+ if (!_drunes_icon.Load("img/icons/drunes.png"))
+ PRINT_WARNING << "Failed to load drunes icon image" << std::endl;
+
+ if (!_star_icon.Load("img/menus/star.png"))
+ PRINT_WARNING << "Failed to load star icon image" << std::endl;
+
+ if (!_check_icon.Load("img/menus/green_check.png"))
+ PRINT_WARNING << "Failed to load check icon image" << std::endl;
+
+ if (!_x_icon.Load("img/menus/red_x.png"))
+ PRINT_WARNING << "Failed to load x icon image" << std::endl;
+
+ if (!_shard_slot_icon.Load("img/menus/shard.png"))
+ PRINT_WARNING << "Failed to load shard icon image" << std::endl;
+
+ if (!_equip_icon.Load("img/menus/equip.png"))
+ PRINT_WARNING << "Failed to load equip icon image" << std::endl;
+
+ if(!hoa_video::ImageDescriptor::LoadMultiImageFromElementGrid(_elemental_icons, "img/icons/effects/elemental.png", 7, 9))
+ PRINT_WARNING << "Failed to load elemental icon images" << std::endl;
+
+ if(!hoa_video::ImageDescriptor::LoadMultiImageFromElementSize(_status_icons, "img/icons/effects/status.png", 25, 25))
+ PRINT_WARNING << "Failed to load status icon images" << std::endl;
+
+ if(!hoa_video::ImageDescriptor::LoadMultiImageFromElementGrid(_all_category_icons, "img/icons/object_category_icons.png", 3, 3))
+ PRINT_WARNING << "Failed to load object category icon images" << std::endl;
+
+ // Load common sounds
+ _LoadSoundFile("confirm", "snd/confirm.wav");
+ _LoadSoundFile("cancel", "snd/cancel.wav");
+ _LoadSoundFile("coins", "snd/coins.wav");
+ _LoadSoundFile("bump", "snd/bump.wav");
+ _LoadSoundFile("volume_test", "snd/volume_test.wav");
+ _LoadSoundFile("item_pickup", "snd/itempick2_michel_baradari_oga.wav");
+}
+
+GlobalMedia::~GlobalMedia()
+{
+ // Clear up sounds
+ for(std::map<std::string, hoa_audio::SoundDescriptor *>::iterator it = _sounds.begin(); it != _sounds.end(); ++it)
+ delete it->second;
+ _sounds.clear();
+}
+
+hoa_video::StillImage* GlobalMedia::GetElementalIcon(GLOBAL_ELEMENTAL element_type, GLOBAL_INTENSITY intensity)
+{
+ const uint32 NUMBER_INTENSTIY_LEVELS = 9;
+
+ // Row/col coordinates for where the specific icon can be found in the multi image array
+ uint32 row = 0, col = 0;
+
+ // Elemental type determines the icon's row
+ switch(element_type) {
+ case GLOBAL_ELEMENTAL_FIRE:
+ row = 0;
+ break;
+ case GLOBAL_ELEMENTAL_WATER:
+ row = 1;
+ break;
+ case GLOBAL_ELEMENTAL_VOLT:
+ row = 2;
+ break;
+ case GLOBAL_ELEMENTAL_EARTH:
+ row = 3;
+ break;
+ case GLOBAL_ELEMENTAL_LIFE:
+ row = 4;
+ break;
+ case GLOBAL_ELEMENTAL_DEATH:
+ row = 5;
+ break;
+ case GLOBAL_ELEMENTAL_NEUTRAL:
+ row = 6;
+ break;
+ default:
+ PRINT_WARNING << "Invalid elemental type: " << element_type << std::endl;
+ return NULL;
+ }
+
+ // Intensity determines the icon's column
+ switch(intensity) {
+ case GLOBAL_INTENSITY_POS_EXTREME:
+ col = 0;
+ break;
+ case GLOBAL_INTENSITY_POS_GREATER:
+ col = 1;
+ break;
+ case GLOBAL_INTENSITY_POS_MODERATE:
+ col = 2;
+ break;
+ case GLOBAL_INTENSITY_POS_LESSER:
+ col = 3;
+ break;
+ case GLOBAL_INTENSITY_NEUTRAL:
+ col = 4;
+ break;
+ case GLOBAL_INTENSITY_NEG_LESSER:
+ col = 5;
+ break;
+ case GLOBAL_INTENSITY_NEG_MODERATE:
+ col = 6;
+ break;
+ case GLOBAL_INTENSITY_NEG_GREATER:
+ col = 7;
+ break;
+ case GLOBAL_INTENSITY_NEG_EXTREME:
+ col = 8;
+ break;
+ default:
+ PRINT_WARNING << "Invalid intensity level: " << intensity << std::endl;
+ return NULL;
+ }
+
+ return &(_elemental_icons[(row * NUMBER_INTENSTIY_LEVELS) + col]);
+}
+
+hoa_video::StillImage* GlobalMedia::GetItemCategoryIcon(GLOBAL_OBJECT object_type)
+{
+ uint32 index = 0;
+
+ switch(object_type) {
+ case GLOBAL_OBJECT_ITEM:
+ index = 0;
+ break;
+ case GLOBAL_OBJECT_WEAPON:
+ index = 1;
+ break;
+ case GLOBAL_OBJECT_HEAD_ARMOR:
+ index = 2;
+ break;
+ case GLOBAL_OBJECT_TORSO_ARMOR:
+ index = 3;
+ break;
+ case GLOBAL_OBJECT_ARM_ARMOR:
+ index = 4;
+ break;
+ case GLOBAL_OBJECT_LEG_ARMOR:
+ index = 5;
+ break;
+ case GLOBAL_OBJECT_SHARD:
+ index = 6;
+ break;
+ case GLOBAL_OBJECT_TOTAL:
+ index = 7;
+ break;
+ default:
+ return NULL;
+ }
+
+ return &(_all_category_icons[index]);
+}
+
+hoa_video::StillImage* GlobalMedia::GetStatusIcon(GLOBAL_STATUS type, GLOBAL_INTENSITY intensity)
+{
+ if((type <= GLOBAL_STATUS_INVALID) || (type >= GLOBAL_STATUS_TOTAL)) {
+ PRINT_WARNING << "Invalid type: " << type << std::endl;
+ return NULL;
+ }
+
+ if((intensity < GLOBAL_INTENSITY_NEUTRAL) || (intensity >= GLOBAL_INTENSITY_TOTAL)) {
+ PRINT_WARNING << "Invalid intensity: " << intensity << std::endl;
+ return NULL;
+ }
+
+ const uint32 IMAGE_ROWS = 5;
+ return &(_status_icons[(type * IMAGE_ROWS) + intensity]);
+}
+
+void GlobalMedia::PlaySound(const std::string &identifier)
+{
+ std::map<std::string, hoa_audio::SoundDescriptor *>::iterator sound = _sounds.find(identifier);
+ if((sound != _sounds.end()) && sound->second)
+ sound->second->Play();
+}
+
+void GlobalMedia::_LoadSoundFile(const std::string& sound_name, const std::string& filename)
+{
+ if (filename.empty() || sound_name.empty())
+ return;
+
+ _sounds[sound_name] = new hoa_audio::SoundDescriptor();
+ if(!_sounds[sound_name]->LoadAudio(filename))
+ PRINT_WARNING << "Failed to load '" << filename << "' needed by shop mode" << std::endl;
+}
+
} // namespace hoa_global
View
121 src/common/global/global_utils.h
@@ -21,6 +21,17 @@
#define __GLOBAL_UTILS_HEADER__
#include "utils.h"
+#include "engine/video/image.h"
+
+#include <map>
+
+namespace hoa_audio {
+class SoundDescriptor;
+}
+
+namespace hoa_video {
+class StillImage;
+};
namespace hoa_global
{
@@ -282,6 +293,116 @@ bool IncrementIntensity(GLOBAL_INTENSITY &intensity, uint8 amount = 1);
**/
bool DecrementIntensity(GLOBAL_INTENSITY &intensity, uint8 amount = 1);
+/** \brief A simple class used to store commonly used media files.
+*** It is used as a member of the game global class.
+**/
+class GlobalMedia {
+public:
+ GlobalMedia() {}
+
+ ~GlobalMedia();
+
+ //! \brief Loads all the media files.
+ //! Should be called after the final intialization of the VideoManager as
+ //! the texture manager is ready only afterward.
+ void Initialize();
+
+ hoa_video::StillImage* GetDrunesIcon() {
+ return &_drunes_icon;
+ }
+
+ hoa_video::StillImage* GetStarIcon() {
+ return &_star_icon;
+ }
+
+ hoa_video::StillImage* GetCheckIcon() {
+ return &_check_icon;
+ }
+
+ hoa_video::StillImage* GetXIcon() {
+ return &_x_icon;
+ }
+
+ hoa_video::StillImage* GetShardSlotIcon() {
+ return &_shard_slot_icon;
+ }
+
+ hoa_video::StillImage* GetEquipIcon() {
+ return &_equip_icon;
+ }
+
+ hoa_video::StillImage* GetBottomMenuImage() {
+ return &_bottom_menu_image;
+ }
+
+ std::vector<hoa_video::StillImage>* GetAllItemCategoryIcons() {
+ return &_all_category_icons;
+ }
+
+ /** \brief Retrieves the category icon image that represents the specified object type
+ *** \param object_type The type of the global object to retrieve the icon for
+ *** \return A pointer to the image holding the category's icon. NULL if the argument was invalid.
+ *** \note GLOBAL_OBJECT_TOTAL will return the icon for "all wares"
+ **/
+ hoa_video::StillImage* GetItemCategoryIcon(GLOBAL_OBJECT object_type);
+
+ /** \brief Retrieves a specific elemental icon with the proper type and intensity
+ *** \param element_type The type of element the user is trying to retrieve the icon for
+ *** \param intensity The intensity level of the icon to retrieve
+ *** \return The icon representation of the element type and intensity
+ **/
+ hoa_video::StillImage* GetElementalIcon(GLOBAL_ELEMENTAL element_type, GLOBAL_INTENSITY intensity);
+
+ /** \brief Retrieves a specific status icon with the proper type and intensity
+ *** \param status_type The type of status the user is trying to retrieve the icon for
+ *** \param intensity The intensity level of the icon to retrieve
+ *** \return The icon representation of the status type and intensity
+ **/
+ hoa_video::StillImage* GetStatusIcon(GLOBAL_STATUS status_type, GLOBAL_INTENSITY intensity);
+
+ /** \brief Plays a sound object previoulsy loaded
+ *** \param identifier The string identifier for the sound to play
+ **/
+ void PlaySound(const std::string &identifier);
+
+private:
+ //! \brief Retains icon images for all possible object categories, including "all wares"
+ std::vector<hoa_video::StillImage> _all_category_icons;
+
+ //! \brief Image icon representing drunes (currency)
+ hoa_video::StillImage _drunes_icon;
+
+ //! \brief Image icon of a single yellow/gold star
+ hoa_video::StillImage _star_icon;
+
+ //! \brief Image icon of a green check mark
+ hoa_video::StillImage _check_icon;
+
+ //! \brief Image icon of a red x
+ hoa_video::StillImage _x_icon;
+
+ //! \brief Image icon representing open shard slots available on weapons and armors
+ hoa_video::StillImage _shard_slot_icon;
+
+ //! \brief Image icon that represents when a character has a weapon or armor equipped
+ hoa_video::StillImage _equip_icon;
+
+ //! \brief Retains all icon images that represent the game's elementals
+ std::vector<hoa_video::StillImage> _elemental_icons;
+
+ //! \brief Retains all icon images that represent the game's status effects
+ std::vector<hoa_video::StillImage> _status_icons;
+
+ //! \brief The battle and boot bottom image
+ hoa_video::StillImage _bottom_menu_image;
+
+ //! \brief A map of the sounds used in different game modes
+ std::map<std::string, hoa_audio::SoundDescriptor*> _sounds;
+
+ //! \brief Loads a sound file and add it to the sound map
+ void _LoadSoundFile(const std::string& sound_name, const std::string& filename);
+};
+
} // namespace hoa_global
#endif // __GLOBAL_UTILS_HEADER__
View
78 src/modes/battle/battle.cpp
@@ -102,9 +102,6 @@ BattleMedia::BattleMedia()
if(ImageDescriptor::LoadMultiImageFromElementGrid(_target_type_icons, "img/icons/effects/targets.png", 1, 8) == false)
PRINT_ERROR << "failed to load character action buttons" << std::endl;
- if(ImageDescriptor::LoadMultiImageFromElementSize(_status_icons, "img/icons/effects/status.png", 25, 25) == false)
- PRINT_ERROR << "failed to load status icon images" << std::endl;
-
character_HP_text.SetStyle(TextStyle("text18", Color::white));
character_HP_text.SetText(Translate("HP"));
character_SP_text.SetStyle(TextStyle("text18", Color::white));
@@ -116,62 +113,12 @@ BattleMedia::BattleMedia()
if(defeat_music.LoadAudio(DEFAULT_DEFEAT_MUSIC) == false)
IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load defeat music file: " << DEFAULT_DEFEAT_MUSIC << std::endl;
- if(confirm_sound.LoadAudio("snd/confirm.wav") == false)
- IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load confirm sound" << std::endl;
-
- if(cancel_sound.LoadAudio("snd/cancel.wav") == false)
- IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load cancel sound" << std::endl;
-
- if(cursor_sound.LoadAudio("snd/confirm.wav") == false)
- IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load cursor sound" << std::endl;
-
- if(invalid_sound.LoadAudio("snd/cancel.wav") == false)
- IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load invalid sound" << std::endl;
-
- if(finish_sound.LoadAudio("snd/confirm.wav") == false)
- IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load finish sound" << std::endl;
-
- // Determine which status effects correspond to which icons and store the result in the _status_indices container
- ReadScriptDescriptor &script_file = GlobalManager->GetStatusEffectsScript();
-
- std::vector<int32> status_types;
- script_file.ReadTableKeys(status_types);
-
- for(uint32 i = 0; i < status_types.size(); i++) {
- GLOBAL_STATUS status = static_cast<GLOBAL_STATUS>(status_types[i]);
-
- // Check for duplicate entries of the same status effect
- if(_status_indeces.find(status) != _status_indeces.end()) {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "duplicate entry found in file " << script_file.GetFilename() <<
- " for status type: " << status_types[i] << std::endl;
- continue;
- }
-
- script_file.OpenTable(status_types[i]);
- if(script_file.DoesIntExist("icon_index") == true) {
- uint32 icon_index = script_file.ReadUInt("icon_index");
- _status_indeces.insert(std::pair<GLOBAL_STATUS, uint32>(status, icon_index));
- } else {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "no icon_index member was found for status effect: " << status_types[i] << std::endl;
- }
- script_file.CloseTable();
- }
-
// Load the stunned icon
if(!_stunned_icon.Load("img/icons/effects/zzz.png"))
IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load stunned icon" << std::endl;
}
-
-BattleMedia::~BattleMedia()
-{
- battle_music.FreeAudio();
- victory_music.FreeAudio();
- defeat_music.FreeAudio();
-}
-
-
void BattleMedia::Update()
{
attack_point_indicator.Update();
@@ -231,31 +178,6 @@ StillImage *BattleMedia::GetTargetTypeIcon(hoa_global::GLOBAL_TARGET target_type
}
}
-
-
-StillImage *BattleMedia::GetStatusIcon(GLOBAL_STATUS type, GLOBAL_INTENSITY intensity)
-{
- if((type <= GLOBAL_STATUS_INVALID) || (type >= GLOBAL_STATUS_TOTAL)) {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "type argument was invalid: " << type << std::endl;
- return NULL;
- }
- if((intensity < GLOBAL_INTENSITY_NEUTRAL) || (intensity >= GLOBAL_INTENSITY_TOTAL)) {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "type argument was invalid: " << intensity << std::endl;
- return NULL;
- }
-
- std::map<GLOBAL_STATUS, uint32>::iterator status_entry = _status_indeces.find(type);
- if(status_entry == _status_indeces.end()) {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "no entry in the status icon index for status type: " << type << std::endl;
- return NULL;
- }
-
- const uint32 IMAGE_ROWS = 5;
- uint32 status_index = status_entry->second;
- uint32 intensity_index = static_cast<uint32>(intensity);
- return &(_status_icons[(status_index * IMAGE_ROWS) + intensity_index]);
-}
-
} // namespace private_battle
////////////////////////////////////////////////////////////////////////////////
View
26 src/modes/battle/battle.h
@@ -125,7 +125,7 @@ class BattleMedia
public:
BattleMedia();
- ~BattleMedia();
+ ~BattleMedia() {}
///! \brief Updates the different animations and media
void Update();
@@ -152,13 +152,6 @@ class BattleMedia
**/
hoa_video::StillImage *GetTargetTypeIcon(hoa_global::GLOBAL_TARGET target_type);
- /** \brief Retrieves a specific status icon with the proper type and intensity
- *** \param type The type of status effect the user is trying to retrieve the icon for
- *** \param intensity The intensity level of the icon to retrieve
- *** \return The icon representation of the element type and intensity, or NULL if no appropriate image was found
- **/
- hoa_video::StillImage *GetStatusIcon(hoa_global::GLOBAL_STATUS type, hoa_global::GLOBAL_INTENSITY intensity);
-
const hoa_video::StillImage &GetStunnedIcon() {
return _stunned_icon;
}
@@ -220,31 +213,14 @@ class BattleMedia
//! \brief The music played after the player has lost the battle
hoa_audio::MusicDescriptor defeat_music;
-
- //! \brief Various sounds that are played as the player performs menu actions
- //@{
- hoa_audio::SoundDescriptor confirm_sound;
- hoa_audio::SoundDescriptor cancel_sound;
- hoa_audio::SoundDescriptor cursor_sound;
- hoa_audio::SoundDescriptor invalid_sound;
- hoa_audio::SoundDescriptor finish_sound;
//@}
private:
- /** \brief Container used to find the appropriate row index for each status type
- *** Status icons for all types of status are all contained within a single image. This container is used to
- *** quickly determine which row of icons in that image corresponds to each status type.
- **/
- std::map<hoa_global::GLOBAL_STATUS, uint32> _status_indeces;
-
/** \brief Holds icon images that represent the different types of targets
*** Target types include attack points, ally/enemy, and different parties.
**/
std::vector<hoa_video::StillImage> _target_type_icons;
- //! \brief Contains the entire set of status effect icons
- std::vector<hoa_video::StillImage> _status_icons;
-
//! \brief An icon displayed above the character's head when it is stunned.
hoa_video::StillImage _stunned_icon;
}; // class BattleMedia
View
60 src/modes/battle/battle_command.cpp
@@ -536,11 +536,11 @@ void ItemCommand::UpdateList()
if(InputManager->UpPress()) {
_item_list.InputUp();
_item_target_list.InputUp();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else if(InputManager->DownPress()) {
_item_list.InputDown();
_item_target_list.InputDown();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
@@ -705,11 +705,11 @@ void SkillCommand::UpdateList()
if(InputManager->UpPress()) {
_skill_list->InputUp();
_target_n_cost_list->InputUp();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else if(InputManager->DownPress()) {
_skill_list->InputDown();
_target_n_cost_list->InputDown();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
@@ -982,13 +982,13 @@ void CommandSupervisor::NotifyActorDeath(BattleActor *actor)
// If the character currently selecting a command dies, we get out.
if(character == actor) {
_ChangeState(COMMAND_STATE_INVALID);
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
return;
}
// Update the selected target if the target is the actor who just deceased
if(_selected_target.GetActor() == actor) {
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
// Try selecting the next actor and fall back to the previous command menu
// if not possible.
@@ -1078,7 +1078,7 @@ bool CommandSupervisor::_SetInitialTarget()
if(!_selected_target.SetInitialTarget(user, target_type)) {
// No more target of that type, let's go back to the command state
_selected_target.InvalidateTarget();
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
return false;
}
}
@@ -1143,7 +1143,7 @@ void CommandSupervisor::_ChangeState(COMMAND_STATE new_state)
// Set the initial target if we're coming from the action selection state
if(_state == COMMAND_STATE_ACTION) {
if(!_SetInitialTarget()) {
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
return;
}
}
@@ -1172,11 +1172,11 @@ void CommandSupervisor::_UpdateCategory()
// is allowed to continue.
if((BM->GetBattleType() == BATTLE_TYPE_WAIT || BM->GetBattleType() == BATTLE_TYPE_SEMI_ACTIVE)
&& (GetCommandCharacter()->GetState() == ACTOR_STATE_COMMAND)) {
- BM->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
} else {
_ChangeState(COMMAND_STATE_INVALID);
BM->NotifyCommandCancel();
- BM->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
}
@@ -1184,20 +1184,20 @@ void CommandSupervisor::_UpdateCategory()
if(_category_options.IsOptionEnabled(_category_options.GetSelection())) {
_active_settings->SetLastCategory(_category_options.GetSelection());
_ChangeState(COMMAND_STATE_ACTION);
- BattleMode::CurrentInstance()->GetMedia().confirm_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else {
- BattleMode::CurrentInstance()->GetMedia().invalid_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
}
else if(InputManager->LeftPress()) {
_category_options.InputLeft();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
else if(InputManager->RightPress()) {
_category_options.InputRight();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
@@ -1207,7 +1207,7 @@ void CommandSupervisor::_UpdateAction()
{
if(InputManager->CancelPress()) {
_ChangeState(COMMAND_STATE_CATEGORY);
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
return;
}
@@ -1218,15 +1218,15 @@ void CommandSupervisor::_UpdateAction()
bool is_skill_enabled = _skill_command.GetSelectedSkillEnabled();
if(is_skill_enabled == true) {
_ChangeState(COMMAND_STATE_ACTOR);
- BattleMode::CurrentInstance()->GetMedia().confirm_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else {
- BattleMode::CurrentInstance()->GetMedia().invalid_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
}
else if(InputManager->MenuPress()) {
_ChangeState(COMMAND_STATE_INFORMATION);
- BattleMode::CurrentInstance()->GetMedia().confirm_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
else {
@@ -1239,15 +1239,15 @@ void CommandSupervisor::_UpdateAction()
// Permit the selection only where are items left.
if(_selected_item != NULL && _item_command.IsSelectedItemAvailable()) {
_ChangeState(COMMAND_STATE_ACTOR);
- BattleMode::CurrentInstance()->GetMedia().confirm_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else {
- BattleMode::CurrentInstance()->GetMedia().invalid_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
}
else if(InputManager->MenuPress()) {
_ChangeState(COMMAND_STATE_INFORMATION);
- BattleMode::CurrentInstance()->GetMedia().confirm_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
else {
@@ -1266,7 +1266,7 @@ void CommandSupervisor::_UpdateActorTarget()
{
if(InputManager->CancelPress()) {
_ChangeState(COMMAND_STATE_ACTION);
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
else if(InputManager->ConfirmPress()) {
@@ -1289,7 +1289,7 @@ void CommandSupervisor::_UpdateActorTarget()
if((IsTargetActor(_selected_target.GetType()) == true) || (IsTargetPoint(_selected_target.GetType()) == true)) {
_selected_target.SelectNextActor(GetCommandCharacter(), direction, true, permit_dead_targets);
_CreateActorTargetText();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
}
@@ -1300,7 +1300,7 @@ void CommandSupervisor::_UpdateAttackPointTarget()
{
if(InputManager->CancelPress()) {
_ChangeState(COMMAND_STATE_ACTOR);
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
else if(InputManager->ConfirmPress()
@@ -1316,7 +1316,7 @@ void CommandSupervisor::_UpdateAttackPointTarget()
_selected_target.SelectNextPoint(GetCommandCharacter(), InputManager->DownPress());
_CreateAttackPointTargetText();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
@@ -1326,12 +1326,12 @@ void CommandSupervisor::_UpdateInformation()
{
if(InputManager->CancelPress() || InputManager->MenuPress()) {
_state = COMMAND_STATE_ACTION;
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
else if(InputManager->ConfirmPress()) {
_ChangeState(COMMAND_STATE_ACTOR);
- BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
+ GlobalManager->Media().PlaySound("cancel");
}
// Change selected skill/item and update the information text
@@ -1340,11 +1340,11 @@ void CommandSupervisor::_UpdateInformation()
if(_IsSkillCategorySelected() == true) {
_skill_command.UpdateList();
_selected_skill = _skill_command.GetSelectedSkill();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
} else if(_IsItemCategorySelected() == true) {
_item_command.UpdateList();
_selected_item = _item_command.GetSelectedItem();
- BattleMode::CurrentInstance()->GetMedia().cursor_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
_CreateInformationText();
@@ -1540,7 +1540,7 @@ void CommandSupervisor::_FinalizeCommand()
_ChangeState(COMMAND_STATE_INVALID);
BattleMode::CurrentInstance()->NotifyCharacterCommandComplete(character);
- BattleMode::CurrentInstance()->GetMedia().finish_sound.Play();
+ GlobalManager->Media().PlaySound("confirm");
}
} // namespace private_battle
View
4 src/modes/battle/battle_effects.cpp
@@ -115,7 +115,7 @@ BattleStatusEffect::BattleStatusEffect(GLOBAL_STATUS type, GLOBAL_INTENSITY inte
// --- (4): Finish initialization of members
_timer.Reset();
_timer.Run();
- _icon_image = BattleMode::CurrentInstance()->GetMedia().GetStatusIcon(_type, _intensity);
+ _icon_image = GlobalManager->Media().GetStatusIcon(_type, _intensity);
}
@@ -160,7 +160,7 @@ void BattleStatusEffect::_ProcessIntensityChange(bool reset_timer_only)
return;
_intensity_changed = true;
- _icon_image = BattleMode::CurrentInstance()->GetMedia().GetStatusIcon(_type, _intensity);
+ _icon_image = GlobalManager->Media().GetStatusIcon(_type, _intensity);
}
////////////////////////////////////////////////////////////////////////////////
View
8 src/modes/battle/battle_indicators.cpp
@@ -17,7 +17,7 @@
#include "engine/system.h"
#include "engine/video/video.h"
-#include "common/global/global_utils.h"
+#include "common/global/global.h"
#include "modes/battle/battle.h"
#include "modes/battle/battle_actors.h"
@@ -566,13 +566,13 @@ void IndicatorSupervisor::AddStatusIndicator(GLOBAL_STATUS old_status, GLOBAL_IN
{
// If the status and intensity has not changed, only a single status icon needs to be used
if((old_status == new_status) && (old_intensity == new_intensity)) {
- StillImage *image = BattleMode::CurrentInstance()->GetMedia().GetStatusIcon(new_status, new_intensity);
+ StillImage *image = GlobalManager->Media().GetStatusIcon(new_status, new_intensity);
_wait_queue.push_back(new IndicatorImage(_actor, *image, POSITIVE_STATUS_EFFECT_INDICATOR));
}
// Otherwise two status icons need to be used in the indicator image
else {
- StillImage *first_image = BattleMode::CurrentInstance()->GetMedia().GetStatusIcon(old_status, old_intensity);
- StillImage *second_image = BattleMode::CurrentInstance()->GetMedia().GetStatusIcon(new_status, new_intensity);
+ StillImage *first_image = GlobalManager->Media().GetStatusIcon(old_status, old_intensity);
+ StillImage *second_image = GlobalManager->Media().GetStatusIcon(new_status, new_intensity);
INDICATOR_TYPE indicator_type = IsNewStatusBetter(new_status, old_intensity, new_intensity) ?
POSITIVE_STATUS_EFFECT_INDICATOR : NEGATIVE_STATUS_EFFECT_INDICATOR;
_wait_queue.push_back(new IndicatorBlendedImage(_actor, *first_image, *second_image, indicator_type));
View
19 src/modes/boot/boot.cpp
@@ -142,12 +142,7 @@ BootMode::BootMode() :
_boot_timer.EnableManualUpdate();
_boot_timer.Run();
- // Preload test sound
- AudioManager->LoadSound("snd/volume_test.wav", this);
- // Preload main sounds
- AudioManager->LoadSound("snd/confirm.wav", this);
- AudioManager->LoadSound("snd/cancel.wav", this);
- AudioManager->LoadSound("snd/bump.wav", this);
+ // Preload new game sound
AudioManager->LoadSound("snd/new_game.wav", this);
} // BootMode::BootMode()
@@ -240,7 +235,7 @@ void BootMode::Update()
if(help_window && help_window->IsActive()) {
// Any key, except F1
if(!InputManager->HelpPress() && InputManager->AnyKeyPress()) {
- AudioManager->PlaySound("snd/confirm.wav");
+ GlobalManager->Media().PlaySound("confirm");
help_window->Hide();
}
return;
@@ -327,10 +322,10 @@ void BootMode::Update()
if(_active_menu->IsOptionEnabled(_active_menu->GetSelection())) {
// Don't play the sound on New Games as they have their own sound
if(_active_menu != &_main_menu && _active_menu->GetSelection() != -1)
- AudioManager->PlaySound("snd/confirm.wav");
+ GlobalManager->Media().PlaySound("confirm");
} else {
// Otherwise play a different sound
- AudioManager->PlaySound("snd/bump.wav");
+ GlobalManager->Media().PlaySound("bump");
}
_active_menu->InputConfirm();
@@ -364,7 +359,7 @@ void BootMode::Update()
}
// Play cancel sound
- AudioManager->PlaySound("snd/cancel.wav");
+ GlobalManager->Media().PlaySound("cancel");
}
} // void BootMode::Update()
@@ -924,7 +919,7 @@ void BootMode::_OnSoundLeft()
AudioManager->SetSoundVolume(AudioManager->GetSoundVolume() - 0.1f);
_RefreshAudioOptions();
// Play a sound for user to hear new volume level.
- AudioManager->PlaySound("snd/volume_test.wav");
+ GlobalManager->Media().PlaySound("volume_test");
_has_modified_settings = true;
}
@@ -935,7 +930,7 @@ void BootMode::_OnSoundRight()
AudioManager->SetSoundVolume(AudioManager->GetSoundVolume() + 0.1f);
_RefreshAudioOptions();
// Play a sound for user to hear new volume level.
- AudioManager->PlaySound("snd/volume_test.wav");
+ GlobalManager->Media().PlaySound("volume_test");
_has_modified_settings = true;
}
View
19 src/modes/map/map_treasure.cpp
@@ -114,8 +114,6 @@ TreasureSupervisor::TreasureSupervisor() :
_list_options.SetCursorOffset(-50.0f, -25.0f);
_list_options.SetTextStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2));
_list_options.SetOwner(&_list_window);
- // TODO: this currently does not work (text will be blank). Re-enable it once the scissoring bug is fixed in the video engine
-// _list_options.Scissoring(true, true);
_detail_textbox.SetPosition(20.0f, 90.0f);
_detail_textbox.SetDimensions(726.0f, 128.0f);
@@ -126,17 +124,6 @@ TreasureSupervisor::TreasureSupervisor() :
_detail_textbox.SetOwner(&_list_window);
_selection_name.SetStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2));
-
- if(!_drunes_icon.Load("img/icons/drunes.png"))
- IF_PRINT_WARNING(MAP_DEBUG) << "failed to load drunes icon for treasure menu" << std::endl;
-
- if(!_coins_snd.LoadAudio("snd/coins.wav"))
- IF_PRINT_WARNING(MAP_DEBUG) << "failed to load the obtain sound for Drunes treasures" << std::endl;
- _coins_snd.AddOwner(MapMode::CurrentInstance());
-
- if(!_items_snd.LoadAudio("snd/itempick2_michel_baradari_oga.wav"))
- IF_PRINT_WARNING(MAP_DEBUG) << "failed to load the obtain sound for Items treasures" << std::endl;
- _items_snd.AddOwner(MapMode::CurrentInstance());
} // TreasureSupervisor::TreasureSupervisor()
TreasureSupervisor::~TreasureSupervisor()
@@ -167,9 +154,9 @@ void TreasureSupervisor::Initialize(MapTreasure *treasure)
// Construct the object list, including any drunes that were contained within the treasure
if(_treasure->_drunes != 0) {
_list_options.AddOption(MakeUnicodeString("<img/icons/drunes.png> Drunes<R>" + NumberToString(_treasure->_drunes)));
- _coins_snd.Play();
+ GlobalManager->Media().PlaySound("coins");
} else {
- _items_snd.Play();
+ GlobalManager->Media().PlaySound("item_pickup");
}
for(uint32 i = 0; i < _treasure->_objects_list.size(); i++) {
@@ -325,7 +312,7 @@ void TreasureSupervisor::_UpdateList()
uint32 list_selection = _list_options.GetSelection();
if(list_selection == 0 && _treasure->_drunes != 0) { // If true, the drunes have been selected
_selection_name.SetText(UTranslate("Drunes"));
- _selection_icon = &_drunes_icon;
+ _selection_icon = GlobalManager->Media().GetDrunesIcon();
_detail_textbox.SetDisplayText(VTranslate("With the additional %u drunes found in this treasure added, "
"the party now holds a total of %u drunes.",
_treasure->_drunes, GlobalManager->GetDrunes()));
View
7 src/modes/map/map_treasure.h
@@ -194,13 +194,6 @@ class TreasureSupervisor
//! \brief A pointer to the image of the selected list item
hoa_video::StillImage *_selection_icon;
- //! \brief Holds the icon image that represent drunes
- hoa_video::StillImage _drunes_icon;
-
- //! \brief The "Obtained" sound, played at opening.
- hoa_audio::SoundDescriptor _coins_snd;
- hoa_audio::SoundDescriptor _items_snd;
-
// ---------- Private methods
//! \brief Processes user input when the action sub-window is selected
View
4 src/modes/menu/menu_views.cpp
@@ -238,7 +238,7 @@ void InventoryWindow::Update()
{
//bool cancel = false;
- if(GlobalManager->GetInventory()->size() == 0) {
+ if(GlobalManager->GetInventory()->empty()) {
// no more items in inventory, exit inventory window
Activate(false);
return;
@@ -247,7 +247,7 @@ void InventoryWindow::Update()
// Points to the active option box
OptionBox *active_option = NULL;
- _inventory_items.Update(SystemManager->GetUpdateTime()); //For scrolling
+ _inventory_items.Update(); //For scrolling
switch(_active_box) {
case ITEM_ACTIVE_CATEGORY:
View
266 src/modes/shop/shop.cpp
@@ -66,49 +66,6 @@ namespace private_shop
ShopMedia::ShopMedia()
{
- if(_drunes_icon.Load("img/icons/drunes.png") == false)
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load drunes icon image" << std::endl;
-
- if(_star_icon.Load("img/menus/star.png") == false)
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load star icon image" << std::endl;
-
- if(_check_icon.Load("img/menus/green_check.png") == false)
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load check icon image" << std::endl;
-
- if(_x_icon.Load("img/menus/red_x.png") == false)
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load x icon image" << std::endl;
-
- if(!_shard_slot_icon.Load("img/menus/shard.png"))
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load shard icon image" << std::endl;
-
- if(_equip_icon.Load("img/menus/equip.png") == false)
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load equip icon image" << std::endl;
-
- if(!ImageDescriptor::LoadMultiImageFromElementGrid(_elemental_icons, "img/icons/effects/elemental.png", 7, 9))
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load elemental icon images" << std::endl;
-
- if(!ImageDescriptor::LoadMultiImageFromElementSize(_status_icons, "img/icons/effects/status.png", 25, 25))
- PRINT_ERROR << "failed to load status icon images" << std::endl;
-
- _sounds["confirm"] = new SoundDescriptor();
- _sounds["cancel"] = new SoundDescriptor();
- _sounds["coins"] = new SoundDescriptor();
- _sounds["bump"] = new SoundDescriptor();
-
- uint32 sound_load_failures = 0;
- if(_sounds["confirm"]->LoadAudio("snd/confirm.wav") == false)
- sound_load_failures++;
- if(_sounds["cancel"]->LoadAudio("snd/cancel.wav") == false)
- sound_load_failures++;
- if(_sounds["coins"]->LoadAudio("snd/coins.wav") == false)
- sound_load_failures++;
- if(_sounds["bump"]->LoadAudio("snd/bump.wav") == false)
- sound_load_failures++;
-
- if(sound_load_failures > 0) {
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load " << sound_load_failures << " sounds needed by shop mode" << std::endl;
- }
-
_all_category_names.push_back(UTranslate("Items"));
_all_category_names.push_back(UTranslate("Weapons"));
_all_category_names.push_back(UTranslate("Head Armor"));
@@ -119,54 +76,11 @@ ShopMedia::ShopMedia()
_all_category_names.push_back(UTranslate("Key Items"));
_all_category_names.push_back(UTranslate("All Wares"));
- if(!ImageDescriptor::LoadMultiImageFromElementGrid(_all_category_icons, "img/icons/object_category_icons.png", 3, 4))
- IF_PRINT_WARNING(SHOP_DEBUG) << "failed to load object category icon images" << std::endl;
-
- // The last three images in this multi image are blank, so they are removed
- _all_category_icons.pop_back();
- _all_category_icons.pop_back();
- _all_category_icons.pop_back();
-
- // Determine which status effects correspond to which icons and store the result in the _status_indices container
- hoa_script::ReadScriptDescriptor &script_file = GlobalManager->GetStatusEffectsScript();
-
- std::vector<int32> status_types;
- script_file.ReadTableKeys(status_types);
-
- for(uint32 i = 0; i < status_types.size(); ++i) {
- GLOBAL_STATUS status = static_cast<GLOBAL_STATUS>(status_types[i]);
-
- // Check for duplicate entries of the same status effect
- if(_status_indeces.find(status) != _status_indeces.end()) {
- IF_PRINT_WARNING(SHOP_DEBUG) << "duplicate entry found in file " << script_file.GetFilename() <<
- " for status type: " << status_types[i] << std::endl;
- continue;
- }
-
- script_file.OpenTable(status_types[i]);
- if(script_file.DoesIntExist("icon_index") == true) {
- uint32 icon_index = script_file.ReadUInt("icon_index");
- _status_indeces.insert(std::pair<GLOBAL_STATUS, uint32>(status, icon_index));
- } else {
- IF_PRINT_WARNING(SHOP_DEBUG) << "no icon_index member was found for status effect: " << status_types[i] << std::endl;
- }
- script_file.CloseTable();
- }
-
// Initialize the character's prites images.
_InitializeCharacters();
}
-
-ShopMedia::~ShopMedia()
-{
- for(std::map<std::string, SoundDescriptor *>::iterator i = _sounds.begin(); i != _sounds.end(); i++)
- delete i->second;
- _sounds.clear();
-}
-
-
void ShopMedia::_InitializeCharacters()
{
// Grab the sprite frames for all characters in the active party
@@ -223,149 +137,6 @@ ustring *ShopMedia::GetCategoryName(GLOBAL_OBJECT object_type)
return &(_all_category_names[index]);
}
-
-StillImage *ShopMedia::GetCategoryIcon(GLOBAL_OBJECT object_type)
-{
- uint32 index = 0;
-
- switch(object_type) {
- case GLOBAL_OBJECT_ITEM:
- index = 0;
- break;
- case GLOBAL_OBJECT_WEAPON:
- index = 1;
- break;
- case GLOBAL_OBJECT_HEAD_ARMOR:
- index = 2;
- break;
- case GLOBAL_OBJECT_TORSO_ARMOR:
- index = 3;
- break;
- case GLOBAL_OBJECT_ARM_ARMOR:
- index = 4;
- break;
- case GLOBAL_OBJECT_LEG_ARMOR:
- index = 5;
- break;
- case GLOBAL_OBJECT_SHARD:
- index = 6;
- break;
- case GLOBAL_OBJECT_TOTAL:
- index = 7;
- break;
- default:
- return NULL;
- }
-
- return &(_all_category_icons[index]);
-}
-
-
-StillImage *ShopMedia::GetElementalIcon(GLOBAL_ELEMENTAL element_type, GLOBAL_INTENSITY intensity)
-{
- const uint32 NUMBER_INTENSTIY_LEVELS = 9;
-
- // Row/col coordinates for where the specific icon can be found in the multi image array
- uint32 row = 0, col = 0;
-
- // Elemental type determines the icon's row
- switch(element_type) {
- case GLOBAL_ELEMENTAL_FIRE:
- row = 0;
- break;
- case GLOBAL_ELEMENTAL_WATER:
- row = 1;
- break;
- case GLOBAL_ELEMENTAL_VOLT:
- row = 2;
- break;
- case GLOBAL_ELEMENTAL_EARTH:
- row = 3;
- break;
- case GLOBAL_ELEMENTAL_LIFE:
- row = 4;
- break;
- case GLOBAL_ELEMENTAL_DEATH:
- row = 5;
- break;
- case GLOBAL_ELEMENTAL_NEUTRAL:
- row = 6;
- break;
- default:
- IF_PRINT_WARNING(SHOP_DEBUG) << "invalid elemental type: " << element_type << std::endl;
- return NULL;
- }
-
- // Intensity determines the icon's column
- switch(intensity) {
- case GLOBAL_INTENSITY_POS_EXTREME:
- col = 0;
- break;
- case GLOBAL_INTENSITY_POS_GREATER:
- col = 1;
- break;
- case GLOBAL_INTENSITY_POS_MODERATE:
- col = 2;
- break;
- case GLOBAL_INTENSITY_POS_LESSER:
- col = 3;
- break;
- case GLOBAL_INTENSITY_NEUTRAL:
- col = 4;
- break;
- case GLOBAL_INTENSITY_NEG_LESSER:
- col = 5;
- break;
- case GLOBAL_INTENSITY_NEG_MODERATE:
- col = 6;
- break;
- case GLOBAL_INTENSITY_NEG_GREATER:
- col = 7;
- break;
- case GLOBAL_INTENSITY_NEG_EXTREME:
- col = 8;
- break;
- default:
- IF_PRINT_WARNING(SHOP_DEBUG) << "invalid intensity level: " << intensity << std::endl;
- return NULL;
- }
-
- return &(_elemental_icons[(row * NUMBER_INTENSTIY_LEVELS) + col]);
-}
-
-StillImage *ShopMedia::GetStatusIcon(GLOBAL_STATUS type, GLOBAL_INTENSITY intensity)
-{
- if((type <= GLOBAL_STATUS_INVALID) || (type >= GLOBAL_STATUS_TOTAL)) {
- PRINT_WARNING << "type argument was invalid: " << type << std::endl;
- return NULL;
- }
- if((intensity < GLOBAL_INTENSITY_NEUTRAL) || (intensity >= GLOBAL_INTENSITY_TOTAL)) {
- PRINT_WARNING << "type argument was invalid: " << intensity << std::endl;
- return NULL;
- }
-
- std::map<GLOBAL_STATUS, uint32>::iterator status_entry = _status_indeces.find(type);
- if(status_entry == _status_indeces.end()) {
- PRINT_WARNING << "no entry in the status icon index for status type: " << type << std::endl;
- return NULL;
- }
-
- const uint32 IMAGE_ROWS = 5;
- uint32 status_index = status_entry->second;
- uint32 intensity_index = static_cast<uint32>(intensity);
- return &(_status_icons[(status_index * IMAGE_ROWS) + intensity_index]);
-}
-
-SoundDescriptor *ShopMedia::GetSound(const std::string &identifier)
-{
- std::map<std::string, SoundDescriptor *>::iterator sound = _sounds.find(identifier);
- if(sound != _sounds.end()) {
- return sound->second;
- } else {
- return NULL;
- }
-}
-
// *****************************************************************************
// ***** ShopObjectViewer class methods
// *****************************************************************************
@@ -463,10 +234,11 @@ void ShopObjectViewer::Initialize()
_count_text.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow());
_hint_text.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow());
- _check_icon = ShopMode::CurrentInstance()->Media()->GetCheckIcon();
- _x_icon = ShopMode::CurrentInstance()->Media()->GetXIcon();
- _shard_slot_icon = ShopMode::CurrentInstance()->Media()->GetShardSlotIcon();
- _equip_icon = ShopMode::CurrentInstance()->Media()->GetEquipIcon();
+ GlobalMedia& media = GlobalManager->Media();
+ _check_icon = media.GetCheckIcon();
+ _x_icon = media.GetXIcon();
+ _shard_slot_icon = media.GetShardSlotIcon();
+ _equip_icon = media.GetEquipIcon();
std::vector<hoa_video::AnimatedImage>* animations = ShopMode::CurrentInstance()->Media()->GetCharacterSprites();
uint32 number_character = animations->size();
@@ -969,7 +741,7 @@ void ShopObjectViewer::_SetElementalIcons(const std::vector<std::pair<GLOBAL_ELE
for(std::vector<std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY> >::const_iterator it = elemental_effects.begin();
it != elemental_effects.end(); ++it) {
if(it->second != GLOBAL_INTENSITY_NEUTRAL)
- _elemental_icons.push_back(ShopMode::CurrentInstance()->Media()->GetElementalIcon(it->first, it->second));
+ _elemental_icons.push_back(GlobalManager->Media().GetElementalIcon(it->first, it->second));
}
}
@@ -979,7 +751,7 @@ void ShopObjectViewer::_SetStatusIcons(const std::vector<std::pair<GLOBAL_STATUS
for(std::vector<std::pair<GLOBAL_STATUS, GLOBAL_INTENSITY> >::const_iterator it = status_effects.begin();
it != status_effects.end(); ++it) {
if(it->second != GLOBAL_INTENSITY_NEUTRAL)
- _status_icons.push_back(ShopMode::CurrentInstance()->Media()->GetStatusIcon(it->first, it->second));
+ _status_icons.push_back(GlobalManager->Media().GetStatusIcon(it->first, it->second));
}
}
@@ -1375,8 +1147,6 @@ void ShopMode::Update()
// When the state is at the root interface ,ShopMode needs to process user input and possibly change state
if(_state == SHOP_STATE_ROOT) {
- SoundDescriptor *sound = NULL; // Used to hold pointers of sound objects to play
-
if(InputManager->ConfirmPress()) {
if(_action_options.GetSelection() < 0 || _action_options.GetSelection() > 3) {
IF_PRINT_WARNING(SHOP_DEBUG) << "invalid selection in action window: " << _action_options.GetSelection() << std::endl;
@@ -1385,9 +1155,7 @@ void ShopMode::Update()
}
_action_options.InputConfirm();
- sound = ShopMode::CurrentInstance()->Media()->GetSound("confirm");
- assert(sound != NULL);
- sound->Play();
+ GlobalManager->Media().PlaySound("confirm");
if(_action_options.GetSelection() == 0 && _action_options.IsOptionEnabled(0)) { // Buy
ChangeState(SHOP_STATE_BUY);
@@ -1449,11 +1217,12 @@ void ShopMode::Draw()
_bottom_window.Draw();
_middle_window.Draw(); // Drawn last because the middle window has the middle upper and lower window borders attached
- // ---------- (3): Draw the contents of the top window
+ // Draw the contents of the top window
+ StillImage *drunes_icon = GlobalManager->Media().GetDrunesIcon();
VideoManager->Move(130.0f, 103.0f);
- ShopMode::CurrentInstance()->Media()->GetDrunesIcon()->Draw();
+ drunes_icon->Draw();
VideoManager->MoveRelative(705.0f, 0.0f);
- ShopMode::CurrentInstance()->Media()->GetDrunesIcon()->Draw();
+ drunes_icon->Draw();
VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
VideoManager->Move(512.0f, 111.0f);
@@ -1712,16 +1481,9 @@ void ShopMode::CompleteTransaction()
GlobalManager->AddToInventory(id, count);
//Remove trade condition items from inventory and possibly call RemoveObjectToSell
- // TODO fix error that happens when you trade all of one type of item in a trade
for(uint32 i = 0; i < it->second->GetObject()->GetTradeConditions().size(); ++i) {
- GlobalManager->DecrementObjectCount(it->second->GetObject()->GetTradeConditions()[i].first, it->second->GetObject()->GetTradeConditions()[i].second * count);
- //GlobalObject *new_object = GlobalCreateNewObject(it->second->GetObject()->GetTradeConditions()[i].first, 1);
- //if(new_object != NULL) {
- //ShopObject new_shop_object(new_object);
- //if(new_shop_object.GetOwnCount() == 0){
- //RemoveObjectToSell(new_shop_object.GetObject()->GetID()); Maybe RemoveObjectToSell isn't the problem?
- //}
- //}
+ GlobalManager->DecrementObjectCount(it->second->GetObject()->GetTradeConditions()[i].first,
+ it->second->GetObject()->GetTradeConditions()[i].second * count);
}
if(it->second->GetStockCount() == 0) {
View
102 src/modes/shop/shop.h
@@ -67,48 +67,13 @@ class ShopMedia
public:
ShopMedia();
- ~ShopMedia();
+ ~ShopMedia() {}
+ //! \brief Shop specific category names
std::vector<hoa_utils::ustring>* GetAllCategoryNames() {
return &_all_category_names;
}
- std::vector<hoa_video::StillImage>* GetAllCategoryIcons() {
- return &_all_category_icons;
- }
-
- hoa_video::StillImage *GetDrunesIcon() {
- return &_drunes_icon;
- }
-
- hoa_video::StillImage *GetStarIcon() {
- return &_star_icon;
- }
-
- hoa_video::StillImage *GetCheckIcon() {
- return &_check_icon;
- }
-
- hoa_video::StillImage *GetXIcon() {
- return &_x_icon;
- }
-
- hoa_video::StillImage *GetShardSlotIcon() {
- return &_shard_slot_icon;
- }
-
- hoa_video::StillImage *GetEquipIcon() {
- return &_equip_icon;
- }
-
- std::vector<hoa_video::StillImage>* GetElementalIcons() {
- return &_elemental_icons;
- }
-
- std::vector<hoa_video::StillImage>* GetStatusIcons() {
- return &_status_icons;
- }
-
std::vector<hoa_video::AnimatedImage>* GetCharacterSprites() {
return &_character_sprites;
}
@@ -120,76 +85,13 @@ class ShopMedia
**/
hoa_utils::ustring *GetCategoryName(hoa_global::GLOBAL_OBJECT object_type);
- /** \brief Retrieves the category icon image that represents the specified object type
- *** \param object_type The type of the global object to retrieve the icon for
- *** \return A pointer to the image holding the category's icon. NULL if the argument was invalid.
- *** \note GLOBAL_OBJECT_TOTAL will return the icon for "all wares"
- **/
- hoa_video::StillImage *GetCategoryIcon(hoa_global::GLOBAL_OBJECT object_type);
-
- /** \brief Retrieves a specific elemental icon with the proper type and intensity
- *** \param element_type The type of element the user is trying to retrieve the icon for
- *** \param intensity The intensity level of the icon to retrieve
- *** \return The icon representation of the element type and intensity
- **/
- hoa_video::StillImage *GetElementalIcon(hoa_global::GLOBAL_ELEMENTAL element_type, hoa_global::GLOBAL_INTENSITY intensity);
-
- /** \brief Retrieves a specificstatus icon with the proper type and intensity
- *** \param status_type The type of status the user is trying to retrieve the icon for
- *** \param intensity The intensity level of the icon to retrieve
- *** \return The icon representation of the status type and intensity
- **/
- hoa_video::StillImage *GetStatusIcon(hoa_global::GLOBAL_STATUS status_type, hoa_global::GLOBAL_INTENSITY intensity);
-
- /** \brief Retrieves a shop sound object
- *** \param identifier The string identifier for the sound to retrieve
- *** \return A pointer to the SoundDescriptor, or NULL if no sound had the identifier name
- **/
- hoa_audio::SoundDescriptor *GetSound(const std::string &identifier);
-
private:
- /** \brief Container used to find the appropriate row index for each status type
- *** Status icons for all types of status are all contained within a single image. This container is used to
- *** quickly determine which row of icons in that image corresponds to each status type.
- **/
- std::map<hoa_global::GLOBAL_STATUS, uint32> _status_indeces;
-
//! \brief Retains text names for all possible object categories, including "all wares"
std::vector<hoa_utils::ustring> _all_category_names;
- //! \brief Retains icon images for all possible object categories, including "all wares"
- std::vector<hoa_video::StillImage> _all_category_icons;
-
- //! \brief Image icon representing drunes (currency)
- hoa_video::StillImage _drunes_icon;
-
- //! \brief Image icon of a single yellow/gold star
- hoa_video::StillImage _star_icon;
-
- //! \brief Image icon of a green check mark
- hoa_video::StillImage _check_icon;
-
- //! \brief Image icon of a red x
- hoa_video::StillImage _x_icon;
-
- //! \brief Image icon representing open shard slots available on weapons and armors
- hoa_video::StillImage _shard_slot_icon;
-
- //! \brief Image icon that represents when a character has a weapon or armor equipped
- hoa_video::StillImage _equip_icon;
-
- //! \brief Retains all icon images that represent the game's elementals
- std::vector<hoa_video::StillImage> _elemental_icons;
-
- //! \brief Retains all icon images that represent the game's status effects
- std::vector<hoa_video::StillImage> _status_icons;
-
//! \brief Retains sprite image frames for all characters in the active party
std::vector<hoa_video::AnimatedImage> _character_sprites;
- //! \brief A map of the sounds used in shop mode
- std::map<std::string, hoa_audio::SoundDescriptor *> _sounds;
-
//! \brief Initialize the character's data to show
void _InitializeCharacters();
}; // class ShopMedia
View
24 src/modes/shop/shop_buy.cpp
@@ -139,7 +139,7 @@ void BuyInterface::_RefreshItemCategories()
_category_names.clear();
ShopMedia *shop_media = ShopMode::CurrentInstance()->Media();
std::vector<ustring>* all_category_names = shop_media->GetAllCategoryNames();
- std::vector<StillImage>* all_category_icons = shop_media->GetAllCategoryIcons();
+ std::vector<StillImage>* all_category_icons = GlobalManager->Media().GetAllItemCategoryIcons();
// Determine which categories are used in this shop and populate the true containers with that data
_UpdateAvailableBuyDealTypes();
@@ -303,26 +303,26 @@ void BuyInterface::Update()
_ChangeViewMode(SHOP_VIEW_MODE_INFO);
} else if(InputManager->CancelPress()) {
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ GlobalManager->Media().PlaySound("cancel");
}
// Swap cycles through the object categories
else if(InputManager->MenuPress() && (_number_categories > 1)) {
if(_ChangeCategory(true) == true)
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
// Up/down changes the selected object in the current list
else if(InputManager->UpPress()) {
if(_ChangeSelection(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
} else if(InputManager->DownPress()) {
if(_ChangeSelection(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
} // if (_view_mode == SHOP_VIEW_MODE_LIST)
@@ -332,14 +332,14 @@ void BuyInterface::Update()
_ChangeViewMode(SHOP_VIEW_MODE_LIST);
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
ShopMode::CurrentInstance()->CompleteTransaction();
- //ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
ShopMode::CurrentInstance()->ClearOrder();
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_SELL); //If the entire sell list is emptied, this somehow helps
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_BUY);
} else if(InputManager->CancelPress()) {
_ChangeViewMode(SHOP_VIEW_MODE_LIST);
- while(_list_displays[_current_category]->ChangeBuyQuantity(false) == true) {} //Is this dangerous or inefficient?
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ while(_list_displays[_current_category]->ChangeBuyQuantity(false) == true) {}
+ GlobalManager->Media().PlaySound("cancel");
ShopMode::CurrentInstance()->ClearOrder();
}
@@ -347,15 +347,15 @@ void BuyInterface::Update()
else if(InputManager->LeftPress()) {
if(_list_displays[_current_category]->ChangeBuyQuantity(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
} else if(InputManager->RightPress()) {
if(_list_displays[_current_category]->ChangeBuyQuantity(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
}
}
View
2  src/modes/shop/shop_root.cpp
@@ -120,7 +120,7 @@ void RootInterface::Reinitialize()
// Star images used to construct the composite star rating (30x30 pixel size)
StillImage star, gray_star;
- star = *(ShopMode::CurrentInstance()->Media()->GetStarIcon());
+ star = *(GlobalManager->Media().GetStarIcon());
gray_star = star;
gray_star.EnableGrayScale();
View
26 src/modes/shop/shop_sell.cpp
@@ -139,7 +139,7 @@ void SellInterface::_RefreshItemCategories()
_category_names.clear();
ShopMedia *shop_media = ShopMode::CurrentInstance()->Media();
std::vector<ustring>* all_category_names = shop_media->GetAllCategoryNames();
- std::vector<StillImage>* all_category_icons = shop_media->GetAllCategoryIcons();
+ std::vector<StillImage>* all_category_icons = GlobalManager->Media().GetAllItemCategoryIcons();
// Determine which categories are used in this shop and populate the true containers with that data
_UpdateAvailableSellDealTypes();
@@ -308,42 +308,42 @@ void SellInterface::Update()
_ChangeViewMode(SHOP_VIEW_MODE_INFO);
} else if(InputManager->CancelPress()) {
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ GlobalManager->Media().PlaySound("cancel");
}
// Swap cycles through the object categories
else if(InputManager->MenuPress() && (_number_categories > 1)) {
if(_ChangeCategory(true) == true)
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
// Up/down changes the selected object in the current list
else if(InputManager->UpPress() && (_selected_object != NULL)) {
if(_ChangeSelection(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
} else if(InputManager->DownPress() && (_selected_object != NULL)) {
if(_ChangeSelection(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
} // if (_view_mode == SHOP_VIEW_MODE_LIST)
else if(_view_mode == SHOP_VIEW_MODE_INFO) {
if(InputManager->ConfirmPress()) {
- _ChangeViewMode(SHOP_VIEW_MODE_LIST); //Is this needed?
+ _ChangeViewMode(SHOP_VIEW_MODE_LIST);
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
ShopMode::CurrentInstance()->CompleteTransaction();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
ShopMode::CurrentInstance()->ClearOrder();
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_SELL);
} else if(InputManager->CancelPress()) {
_ChangeViewMode(SHOP_VIEW_MODE_LIST);
- while(_list_displays[_current_category]->ChangeSellQuantity(false) == true) {} //Is this dangerous or inefficient?
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ while(_list_displays[_current_category]->ChangeSellQuantity(false) == true) {}
+ GlobalManager->Media().PlaySound("cancel");
ShopMode::CurrentInstance()->ClearOrder();
}
@@ -351,15 +351,15 @@ void SellInterface::Update()
else if(InputManager->LeftPress()) {
if(_list_displays[_current_category]->ChangeSellQuantity(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
} else if(InputManager->RightPress()) {
if(_list_displays[_current_category]->ChangeSellQuantity(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
}
}
View
26 src/modes/shop/shop_trade.cpp
@@ -129,7 +129,7 @@ void TradeInterface::_RefreshItemCategories()
_category_names.clear();
ShopMedia *shop_media = ShopMode::CurrentInstance()->Media();
std::vector<ustring>* all_category_names = shop_media->GetAllCategoryNames();
- std::vector<StillImage>* all_category_icons = shop_media->GetAllCategoryIcons();
+ std::vector<StillImage>* all_category_icons = GlobalManager->Media().GetAllItemCategoryIcons();
// Determine which categories are used in this shop and populate the true containers with that data
_UpdateAvailableTradeDealTypes();
@@ -288,44 +288,44 @@ void TradeInterface::Update()
_ChangeViewMode(SHOP_VIEW_MODE_INFO);
} else if(InputManager->CancelPress()) {
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ GlobalManager->Media().PlaySound("cancel");
}
// Swap cycles through the object categories
else if(InputManager->MenuPress() && (_number_categories > 1)) {
if(_ChangeCategory(true) == true)
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
// Up/down changes the selected object in the current list
else if(InputManager->UpPress()) {
if(_ChangeSelection(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
} else if(InputManager->DownPress()) {
if(_ChangeSelection(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->SetSelectedObject(_selected_object);
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
}
}
} // if (_view_mode == SHOP_VIEW_MODE_LIST)
else if(_view_mode == SHOP_VIEW_MODE_INFO) {
if(InputManager->ConfirmPress()) {
- _ChangeViewMode(SHOP_VIEW_MODE_LIST); //Is this needed?
+ _ChangeViewMode(SHOP_VIEW_MODE_LIST);
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_ROOT);
ShopMode::CurrentInstance()->CompleteTransaction();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
ShopMode::CurrentInstance()->ClearOrder();
ShopMode::CurrentInstance()->ChangeState(SHOP_STATE_TRADE);
}
if(InputManager->CancelPress()) {
_ChangeViewMode(SHOP_VIEW_MODE_LIST);
- while(_list_displays[_current_category]->ChangeTradeQuantity(false) == true) {} //Is this dangerous or inefficient?
- ShopMode::CurrentInstance()->Media()->GetSound("cancel")->Play();
+ while(_list_displays[_current_category]->ChangeTradeQuantity(false) == true) {}
+ GlobalManager->Media().PlaySound("cancel");
ShopMode::CurrentInstance()->ClearOrder();
}
@@ -333,15 +333,15 @@ void TradeInterface::Update()
else if(InputManager->LeftPress()) {
if(_list_displays[_current_category]->ChangeTradeQuantity(false) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
} else if(InputManager->RightPress()) {
if(_list_displays[_current_category]->ChangeTradeQuantity(true) == true) {
ShopMode::CurrentInstance()->ObjectViewer()->UpdateCountText();
- ShopMode::CurrentInstance()->Media()->GetSound("confirm")->Play();
+ GlobalManager->Media().PlaySound("confirm");
} else
- ShopMode::CurrentInstance()->Media()->GetSound("bump")->Play();
+ GlobalManager->Media().PlaySound("bump");
} else if(InputManager->UpPress()) {
ShopMode::CurrentInstance()->ObjectViewer()->ScrollUpTradeConditions();
} else if(InputManager->DownPress()) {
View
2  src/modes/shop/shop_utils.cpp
@@ -429,7 +429,7 @@ void ObjectCategoryDisplay::SetSelectedObject(ShopObject *shop_object)
} else {
GLOBAL_OBJECT object_type = _selected_object->GetObject()->GetObjectType();
_name_text.SetText(*(ShopMode::CurrentInstance()->Media()->GetCategoryName(object_type)));
- _object_icon = ShopMode::CurrentInstance()->Media()->GetCategoryIcon(object_type);
+ _object_icon = GlobalManager->Media().GetItemCategoryIcon(object_type);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.