예제 #1
0
파일: boot.cpp 프로젝트: joewan/ValyriaTear
void BootMode::Draw()
{
    VideoManager->PushState();
    VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
    VideoManager->SetStandardCoordSys();

    GetScriptSupervisor().DrawBackground();
    GetScriptSupervisor().DrawForeground();
    VideoManager->PopState();
}
예제 #2
0
void MapMode::Draw()
{
    VideoManager->PushState();
    VideoManager->SetStandardCoordSys();
    GetScriptSupervisor().DrawBackground();

    VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    _DrawMapLayers();

    GetScriptSupervisor().DrawForeground();

    VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    _object_supervisor->DrawDialogIcons();
    VideoManager->PopState();
}
예제 #3
0
파일: boot.cpp 프로젝트: joewan/ValyriaTear
void BootMode::DrawPostEffects()
{
    VideoManager->PushState();
    VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
    VideoManager->SetStandardCoordSys();

    GetScriptSupervisor().DrawPostEffects();

    if(_boot_state == BOOT_STATE_MENU) {
        if (!_menu_handler.IsShowingFirstRunLanguageMenu()) {
            VideoManager->Move(0.0f, 640.0f);
            _menu_bar.Draw(Color(1.0f, 1.0f, 1.0f, _menu_bar_alpha));
        }

        VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
        VideoManager->Move(322.0f, 730.0f);
        _f1_help_text.Draw(Color(1.0f, 1.0f, 1.0f, _help_text_alpha));

        VideoManager->Move(10.0f, 758.0f);
        _version_text.Draw();

        _main_menu.Draw();

#ifdef DEBUG_FEATURES
        if (_debug_script_menu_open){
            _debug_scripts_window.Draw();
            _debug_script_menu.Draw();
        }
#endif

        if (_menu_handler.IsActive())
            _menu_handler.Draw();
    }
    VideoManager->PopState();
}
예제 #4
0
void BootMode::DrawPostEffects()
{
    VideoManager->PushState();
    VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
    VideoManager->SetStandardCoordSys();

    GetScriptSupervisor().DrawPostEffects();

    if(_boot_state == BOOT_STATE_MENU) {
        if (!_first_run) {
            VideoManager->Move(0.0f, 640.0f);
            _menu_bar.Draw(Color(1.0f, 1.0f, 1.0f, _menu_bar_alpha));
        }

        VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
        VideoManager->Move(322.0f, 745.0f);
        _f1_help_text.Draw(Color(1.0f, 1.0f, 1.0f, _help_text_alpha));

        VideoManager->Move(10.0f, 758.0f);
        _version_text.Draw();

        _options_window.Draw();
        if(_active_menu)
            _active_menu->Draw();

        VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
        VideoManager->Move(0.0f, 0.0f);
        _message_window.Draw();
    }
    VideoManager->PopState();
}
예제 #5
0
void MapMode::Draw()
{
    VideoManager->SetStandardCoordSys();
    GetScriptSupervisor().DrawBackground();

    VideoManager->SetCoordSys(0.0f, SCREEN_GRID_X_LENGTH, SCREEN_GRID_Y_LENGTH, 0.0f);
    VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    _DrawMapLayers();

    VideoManager->SetStandardCoordSys();
    GetScriptSupervisor().DrawForeground();

    VideoManager->SetCoordSys(0.0f, SCREEN_GRID_X_LENGTH, SCREEN_GRID_Y_LENGTH, 0.0f);
    VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    _object_supervisor->DrawDialogIcons();
}
예제 #6
0
void MapMode::Reset()
{
    _current_instance = this;

    // Reload the active and inactive status effects if necessary
    if (!_activated)
        _status_effect_supervisor.LoadStatusEffects();

    _activated = true;

    // Reset video engine context properties
    VideoManager->SetCoordSys(0.0f, SCREEN_GRID_X_LENGTH, SCREEN_GRID_Y_LENGTH, 0.0f);
    VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);

    // Make the map location known globally to other code that may need to know this information
    GlobalManager->SetMap(_map_data_filename, _map_script_filename,
                          _map_image.GetFilename(), _map_hud_name.GetString());

    _ResetMusicState();

    _intro_timer.Run();

    // Reset potential map scripts
    GetScriptSupervisor().Reset();

    // If the sprite is based on the battle formation, we'd better refresh the data now
    // if the game in in the default mode.
    // Still, we won't change the sprite in the middle of a scene for instance.
    // I.e: When going out of the menu mode.
    if(CurrentState() == private_map::STATE_EXPLORE)
        _object_supervisor->ReloadVisiblePartyMember();
}
예제 #7
0
void BootMode::Reset()
{
    // Set the coordinate system that BootMode uses
    VideoManager->SetStandardCoordSys();
    VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);

    GlobalManager->ClearAllData(); // Resets the game universe to a NULL state
    _current_instance = this;

    GetScriptSupervisor().Reset();
}
예제 #8
0
void MapMode::DrawPostEffects()
{
    VideoManager->PushState();
    VideoManager->SetStandardCoordSys();
    VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    // Halos are additive blending made, so they should be applied
    // as post-effects but before the GUI.
    _object_supervisor->DrawLights();

    GetScriptSupervisor().DrawPostEffects();

    // Draw the gui, unaffected by potential fading effects.
    _DrawGUI();

    if(CurrentState() == STATE_DIALOGUE)
        _dialogue_supervisor->Draw();

    // Draw the treasure menu if necessary
    if(CurrentState() == STATE_TREASURE)
        _treasure_supervisor->Draw();
    VideoManager->PopState();
}
예제 #9
0
파일: boot.cpp 프로젝트: joewan/ValyriaTear
BootMode::BootMode() :
    GameMode(MODE_MANAGER_BOOT_MODE),
    _boot_state(BOOT_STATE_INTRO),
    _exiting_to_new_game(false),
    _new_game_called(false),
    _menu_handler(this),
    _menu_bar_alpha(0.0f),
    _help_text_alpha(0.0f)
{
    _current_instance = this;

#ifdef DEBUG_FEATURES
    _debug_script_menu_open = false;

    // List the debug scripts
    _debug_scripts = vt_utils::ListDirectory("data/debug", ".lua");

    _debug_script_menu.SetPosition(512.0f, 128.0f);
    _debug_script_menu.SetTextStyle(TextStyle("text24"));
    _debug_script_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
    _debug_script_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
    _debug_script_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
    _debug_script_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
    _debug_script_menu.SetCursorOffset(-50.0f, -28.0f);
    _debug_script_menu.SetSkipDisabled(true);

    _debug_script_menu.ClearOptions();
    float debug_win_height = 20.0f * static_cast<float>(_debug_scripts.size());
    _debug_script_menu.SetDimensions(300.0f, debug_win_height > 600.0f ? 600.0f : debug_win_height,
                                     1, 255, 1, _debug_scripts.size());
    for (std::string file : _debug_scripts)
        _debug_script_menu.AddOption(vt_utils::MakeUnicodeString(file));

    // Create the debug window used as background
    _debug_scripts_window.Create(400.0f, 550.0f);
    _debug_scripts_window.SetPosition(310.0f, 58.0f);
    _debug_scripts_window.Hide();
#endif

    // Remove potential previous ambient overlays
    VideoManager->DisableFadeEffect();

    // Note: Not translated on purpose.
    _version_text.SetStyle(TextStyle("text18"));
    std::string version_string = "Version 1.0.0 - Development version";

    // NOTE: Only leave the " - " part for releases.
    version_string.append(" - ");
    version_string.append(__DATE__);
    _version_text.SetText(MakeUnicodeString(version_string));

    // Get rid of the old table to make sure no old data is used.
    ScriptManager->DropGlobalTable("boot");

    // Test the existence and validity of the boot script.
    ReadScriptDescriptor boot_script;
    if(!boot_script.OpenFile("data/boot_menu/boot.lua")) {
        PRINT_ERROR << "Failed to load boot data file" << std::endl;
        SystemManager->ExitGame();
        return;
    }

    // Open the boot table spacename
    if(boot_script.OpenTablespace().empty()) {
        PRINT_ERROR << "The boot script file has not set a correct tablespace" << std::endl;
        SystemManager->ExitGame();
        return;
    }
    boot_script.CloseTable(); // The namespace
    boot_script.CloseFile();

    // Trigger the Initialize functions in the scene script component
    GetScriptSupervisor().AddScript("data/boot_menu/boot.lua");
    GetScriptSupervisor().Initialize(this);

    // Load the menu bar and the help text
    _menu_bar.Load("data/gui/battle/battle_bottom_menu.png", 1024, 128);

    _SetupMainMenu();

    _f1_help_text.SetStyle(TextStyle("text18"));

    // The timer that will be used to display the menu bar and the help text
    _boot_timer.Initialize(14000);
    _boot_timer.EnableManualUpdate();
    _boot_timer.Run();

    // Preload new game sound
    AudioManager->LoadSound("data/sounds/new_game.wav", this);
}
예제 #10
0
BootMode::BootMode() :
    _boot_state(BOOT_STATE_INTRO),
    _exiting_to_new_game(false),
    _has_modified_settings(false),
    _first_run(false),
    _key_setting_function(NULL),
    _joy_setting_function(NULL),
    _joy_axis_setting_function(NULL),
    _message_window(ustring(), 210.0f, 733.0f),
    _menu_bar_alpha(0.0f),
    _help_text_alpha(0.0f)
{
    // Remove potential previous ambient overlays
    VideoManager->DisableFadeEffect();

    IF_PRINT_DEBUG(BOOT_DEBUG) << "BootMode constructor invoked" << std::endl;
    mode_type = MODE_MANAGER_BOOT_MODE;

    // Note: Not translated on purpose.
    _version_text.SetStyle(TextStyle("text18"));
    std::string version_string = "Development Release - ";
    version_string.append(__DATE__);
    _version_text.SetText(MakeUnicodeString(version_string));

    // Get rid of the old table to make sure no old data is used.
    ScriptManager->DropGlobalTable("boot");

    // Test the existence and validity of the boot script.
    ReadScriptDescriptor boot_script;
    if(!boot_script.OpenFile("dat/config/boot.lua")) {
        PRINT_ERROR << "Failed to load boot data file" << std::endl;
        SystemManager->ExitGame();
        return;
    }

    // Open the boot table spacename
    if(boot_script.OpenTablespace().empty()) {
        PRINT_ERROR << "The boot script file has not set a correct tablespace" << std::endl;
        SystemManager->ExitGame();
        return;
    }
    boot_script.CloseTable(); // The namespace
    boot_script.CloseFile();

    // Trigger the Initialize functions in the scene script component
    GetScriptSupervisor().AddScript("dat/config/boot.lua");
    GetScriptSupervisor().Initialize(this);

    _options_window.Create(300.0f, 550.0f);
    _options_window.SetPosition(360.0f, 188.0f);
    _options_window.SetDisplayMode(VIDEO_MENU_INSTANT);
    _options_window.Hide();

    // Setup all boot menu options and properties
    _SetupMainMenu();
    _SetupOptionsMenu();
    _SetupVideoOptionsMenu();
    _SetupAudioOptionsMenu();
    _SetupLanguageOptionsMenu();
    _SetupKeySettingsMenu();
    _SetupJoySettingsMenu();
    _SetupResolutionMenu();
    _active_menu = &_main_menu;

    // make sure message window is not visible
    _message_window.Hide();

    // Load the menu bar and the help text
    _menu_bar.Load("img/menus/battle_bottom_menu.png", 1024, 128);

    _f1_help_text.SetStyle(TextStyle("text18"));

    // The timer that will be used to display the menu bar and the help text
    _boot_timer.Initialize(14000);
    _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);
    AudioManager->LoadSound("snd/new_game.wav", this);
} // BootMode::BootMode()
예제 #11
0
MapMode::MapMode(const std::string& data_filename, const std::string& script_filename, uint32 stamina) :
    GameMode(MODE_MANAGER_MAP_MODE),
    _activated(false),
    _map_data_filename(data_filename),
    _map_script_filename(script_filename),
    _tile_supervisor(NULL),
    _object_supervisor(NULL),
    _event_supervisor(NULL),
    _dialogue_supervisor(NULL),
    _treasure_supervisor(NULL),
    _camera_x_in_map_corner(false),
    _camera_y_in_map_corner(false),
    _camera(NULL),
    _delta_x(0),
    _delta_y(0),
    _pixel_length_x(-1.0f),
    _pixel_length_y(-1.0f),
    _running_disabled(false),
    _unlimited_stamina(false),
    _show_gui(true),
    _run_stamina(stamina),
    _gui_alpha(0.0f),
    _minimap(NULL),
    _show_minimap(false),
    _menu_enabled(true),
    _save_points_enabled(true),
    _status_effects_enabled(true)
{
    _current_instance = this;

    ResetState();
    PushState(STATE_EXPLORE);

    // Load miscellaneous map graphics
    _dialogue_icon.LoadFromAnimationScript("img/misc/dialogue_icon.lua");
    ScaleToMapCoords(_dialogue_icon);

    // Load the save point animation files.
    AnimatedImage anim;
    anim.LoadFromAnimationScript("img/misc/save_point/save_point3.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("img/misc/save_point/save_point2.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("img/misc/save_point/save_point1.lua");
    inactive_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("img/misc/save_point/save_point2.lua");
    inactive_save_point_animations.push_back(anim);

    // Transform the animation size to correspond to the map coordinates system.
    for(uint32 i = 0; i < active_save_point_animations.size(); ++i)
        ScaleToMapCoords(active_save_point_animations[i]);

    for(uint32 i = 0; i < inactive_save_point_animations.size(); ++i)
        ScaleToMapCoords(inactive_save_point_animations[i]);

    _tile_supervisor = new TileSupervisor();
    _object_supervisor = new ObjectSupervisor();
    _event_supervisor = new EventSupervisor();
    _dialogue_supervisor = new DialogueSupervisor();
    _treasure_supervisor = new TreasureSupervisor();

    _intro_timer.Initialize(4000, 0);
    _intro_timer.EnableAutoUpdate(this);

    _camera_timer.Initialize(0, 1);

    if(!_Load()) {
        BootMode *BM = new BootMode();
        ModeManager->PopAll();
        ModeManager->Push(BM);
        return;
    }

    // Once the minimap file has been set (in the load function),
    // we can create the minimap
    if(_show_minimap)
        _CreateMinimap();

    GlobalMedia& media = GlobalManager->Media();
    _stamina_bar_background = media.GetStaminaBarBackgroundImage();
    _stamina_bar = media.GetStaminaBarImage();
    _stamina_bar_infinite_overlay = media.GetStaminaInfiniteImage();

    // Init the script component.
    GetScriptSupervisor().Initialize(this);

    //! Init the camera position text style
    _debug_camera_position.SetStyle(TextStyle("title22", Color::white, VIDEO_TEXT_SHADOW_DARK));
}
예제 #12
0
MapMode::MapMode(const std::string& data_filename, const std::string& script_filename, uint32 stamina) :
    GameMode(MODE_MANAGER_MAP_MODE),
    _activated(false),
    _map_data_filename(data_filename),
    _map_script_filename(script_filename),
    _tile_supervisor(nullptr),
    _object_supervisor(nullptr),
    _event_supervisor(nullptr),
    _dialogue_supervisor(nullptr),
    _treasure_supervisor(nullptr),
    _camera_x_in_map_corner(false),
    _camera_y_in_map_corner(false),
    _camera(nullptr),
    _virtual_focus(nullptr),
    _delta_x(0),
    _delta_y(0),
    _pixel_length_x(-1.0f),
    _pixel_length_y(-1.0f),
    _running_enabled(true),
    _unlimited_stamina(false),
    _show_gui(true),
    _run_stamina(stamina),
    _gui_alpha(0.0f),
    _music_audio_state(AUDIO_STATE_UNLOADED),
    _music_audio_sample(0),
    _minimap(nullptr),
    _show_minimap(false),
    _menu_enabled(true),
    _save_points_enabled(true),
    _status_effects_enabled(true)
{
    _current_instance = this;

    ResetState();
    PushState(STATE_EXPLORE);

    // Load the miscellaneous map graphics.
    _dialogue_icon.LoadFromAnimationScript("data/entities/emotes/dialogue_icon.lua");
    ScaleToMapZoomRatio(_dialogue_icon);

    // Load the save point animation files.
    AnimatedImage anim;
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point3.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point2.lua");
    active_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point1.lua");
    inactive_save_point_animations.push_back(anim);

    anim.Clear();
    anim.LoadFromAnimationScript("data/entities/map/save_point/save_point2.lua");
    inactive_save_point_animations.push_back(anim);

    // Transform the animation size to correspond to the map zoom ratio.
    for(uint32 i = 0; i < active_save_point_animations.size(); ++i)
        ScaleToMapZoomRatio(active_save_point_animations[i]);

    for(uint32 i = 0; i < inactive_save_point_animations.size(); ++i)
        ScaleToMapZoomRatio(inactive_save_point_animations[i]);

    _tile_supervisor = new TileSupervisor();
    _object_supervisor = new ObjectSupervisor();
    _event_supervisor = new EventSupervisor();
    _dialogue_supervisor = new MapDialogueSupervisor();
    _treasure_supervisor = new TreasureSupervisor();

    _intro_timer.Initialize(4000, 0);
    _intro_timer.EnableAutoUpdate(this);

    _camera_timer.Initialize(0, 1);

    // Create the camera virtual focus, used to display random map locations.
    // NOTE: Deleted by the Object supervisor.
    _virtual_focus = new VirtualSprite(NO_LAYER_OBJECT);
    _virtual_focus->SetPosition(0.0f, 0.0f);
    _virtual_focus->SetMovementSpeed(NORMAL_SPEED);
    _virtual_focus->SetCollisionMask(NO_COLLISION);
    _virtual_focus->SetVisible(false);

    if(!_Load()) {
        BootMode *BM = new BootMode();
        ModeManager->PopAll();
        ModeManager->Push(BM);
        return;
    }

    // Once the minimap file has been set (in the load function),
    // we can create the minimap
    if(_show_minimap)
        _CreateMinimap();

    GlobalMedia& media = GlobalManager->Media();
    _stamina_bar_background = media.GetStaminaBarBackgroundImage();
    _stamina_bar = media.GetStaminaBarImage();
    _stamina_bar_infinite_overlay = media.GetStaminaInfiniteImage();

    // Init the script component.
    GetScriptSupervisor().Initialize(this);

    //! Init the camera position text style
    _debug_camera_position.SetStyle(TextStyle("title22", Color::white, VIDEO_TEXT_SHADOW_DARK));
}