commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
174
include/engine/ui/ui.cpp
Normal file
174
include/engine/ui/ui.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "ui/ui_camera.h"
|
||||
#include "ui/ui_sprite.h"
|
||||
#include "ui/ui_ace_manager.h"
|
||||
#include "ui/ui_scene_script_event.h"
|
||||
#include "ui/ui_scene_scripted_object.h"
|
||||
#include "ui/ui_item_script_event.h"
|
||||
#include "ui/ui_item_scripted_object.h"
|
||||
#include "script/script_engine_types.h"
|
||||
#include "log/log.h"
|
||||
|
||||
using namespace GS;
|
||||
using namespace GS::S2D;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Scene::SetClock(Core::Clock *c)
|
||||
{ clock = c ? c : new Core::Clock; }
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Scene::SetCurrentCamera(Camera *camera)
|
||||
{ current_camera = camera ? camera : default_camera.c_ptr(); }
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Item *Scene::ItemFromName(const char *name, Item *parent) const
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
ListForeachPtr(Item *, i, parent->GetChildren())
|
||||
if (i->name == name)
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListForeachPtr(Item *, i, item_list)
|
||||
if (i->name == name)
|
||||
return i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Item *Scene::ItemFromUid(uint uid) const
|
||||
{
|
||||
ListForeachPtr(Item *, i, item_list)
|
||||
if (i->GetUid() == uid)
|
||||
return i;
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
float Scene::GetGlobalFadeEffect() const
|
||||
{ return global_fade_color.w; }
|
||||
void Scene::SetGlobalFadeEffect(float o)
|
||||
{ global_fade_color.w = Types::Clamp(o); }
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Scene::SetupItemComponents(Item *i)
|
||||
{
|
||||
i->scripted_object = new ItemScriptedObject(i, vm);
|
||||
if (vm)
|
||||
i->item_event = new ItemScriptEvent;
|
||||
}
|
||||
void Scene::AddItem(Item *i, bool setup_components)
|
||||
{
|
||||
i->uid = current_item_uid++;
|
||||
|
||||
if (setup_components)
|
||||
SetupItemComponents(i);
|
||||
|
||||
g_ui_messenger.BroadcastMessage(UIMsg_AddingItem, this, (void *)i);
|
||||
item_list.Add(i);
|
||||
g_ui_messenger.BroadcastMessage(UIMsg_ItemAdded, this, (void *)i);
|
||||
}
|
||||
bool Scene::RemoveItem(Item *i)
|
||||
{
|
||||
g_ui_messenger.BroadcastMessage(UIMsg_DeletingItem, this, (void *)i);
|
||||
|
||||
if (lock == i)
|
||||
lock = NULL;
|
||||
item_list.Remove(i);
|
||||
|
||||
g_ui_messenger.BroadcastMessage(UIMsg_ItemDeleted, this, (void *)i);
|
||||
return true;
|
||||
}
|
||||
void Scene::DeleteAllItems()
|
||||
{
|
||||
while (List <Item *> ::Item *i = item_list.GetRoot())
|
||||
RemoveItem(i->Object());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Scene::ExecCommand(ACE::Command *cmd, float dt)
|
||||
{
|
||||
float k = dt / cmd->duration_left;
|
||||
|
||||
switch (cmd->code)
|
||||
{
|
||||
case ACE_globalfade:
|
||||
global_fade_color.w = Types::Clamp(global_fade_color.w + (cmd->parm[0] - global_fade_color.w) * k);
|
||||
return true;
|
||||
}
|
||||
return ACE::Unit::ExecCommand(cmd, dt);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Scene::RenderSetup(Core::ResourceFactories *f)
|
||||
{
|
||||
ListForeachPtr(Item *, item, item_list)
|
||||
item->RenderSetup(f);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Scene::Setup()
|
||||
{
|
||||
scene_event->OnSetup(this);
|
||||
|
||||
// Setup items.
|
||||
ListForeachPtr(Item *, i, item_list)
|
||||
i->Setup();
|
||||
}
|
||||
void Scene::Reset()
|
||||
{
|
||||
scene_event->OnReset(this);
|
||||
}
|
||||
void Scene::Clear()
|
||||
{
|
||||
scene_event->OnDelete(this);
|
||||
|
||||
window_skin = NULL;
|
||||
global_fade_color.Set(0, 0, 0, 0);
|
||||
|
||||
item_list.Clear();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Scene::Scene(Script::IVM *script_vm)
|
||||
{
|
||||
vm = script_vm;
|
||||
lock = NULL;
|
||||
|
||||
current_item_uid = 0;
|
||||
|
||||
clock = new Core::Clock;
|
||||
|
||||
default_camera = new Camera;
|
||||
default_camera->resolution.Set(1280, 960);
|
||||
|
||||
current_camera = default_camera;
|
||||
|
||||
scene_event = vm ? new SceneScriptEvent : new ISceneEvent;
|
||||
scripted_object = new SceneScriptedObject(vm, this);
|
||||
|
||||
global_fade_color.Set(0, 0, 0, 0);
|
||||
}
|
||||
Scene::~Scene()
|
||||
{
|
||||
Clear();
|
||||
if (vm)
|
||||
vm->InvalidateNativeReference((void *)this);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user