AnimatedImage* ScriptSupervisor::CreateAnimation(const std::string& filename)
{
    AnimatedImage* anim = new AnimatedImage();
    if(!filename.empty() && !anim->LoadFromAnimationScript(filename))
        PRINT_WARNING << "The animation file could not be loaded: " << filename << std::endl;

    _animated_images.push_back(anim);
    return anim;
}
int32 ScriptSupervisor::AddAnimation(const std::string& filename) {
	AnimatedImage anim;
	if (!anim.LoadFromAnimationScript(filename)) {
		PRINT_WARNING << "The animation file could not be loaded: " << filename << std::endl;
		return -1;
	}

	_script_animations.push_back(anim);

	int32 id = _script_animations.size() - 1;
	return id;
}
Example #3
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));
}
Example #4
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));
}