commit x64 compilation from lulu cause the other branch dont seems to compile properly at home

This commit is contained in:
2026-07-17 16:08:20 +02:00
parent c0f3eeb00d
commit 0efa4ee6f7
625 changed files with 117283 additions and 4426 deletions

View File

@ -0,0 +1,278 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "scene3d/scene.h"
#include "ui/ui.h"
#include "script/script_engine_types.h"
#include "script/script_variant.h"
#include "metafile/nml_object.h"
#include "platform.h"
using namespace GS::Core;
//------------------------------------------------------------------------------
bool Project::IsProjectActionAllowed(const char *f)
{
if (prohibit_project_action)
__ERR__(__LOG_E__ << "Cannot call '" << f << "' while rendering or evaluating the project scene stack.\n", false)
return true;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void Project::ResetStatistics()
{
ListForeachPtr(ProjectSceneInstance *, i, instance_list)
switch (i->type)
{
case ProjectSceneInstance::Type_Scene2d:
break;
case ProjectSceneInstance::Type_Scene3d:
i->instance_3d->profiler.ResetProfiles();
break;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
uint Project::GetActiveCount() const
{
uint count = 0;
ListForeachPtr(ProjectSceneInstance *, i, instance_list)
if (i->active)
++count;
return count;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ProjectSceneInstance *Project::FindSceneInstance(const char *name) const
{
ListForeachPtr(ProjectSceneInstance *, s, instance_list)
switch (s->GetType())
{
case ProjectSceneInstance::Type_Scene3d:
if (s->instance_3d->name == name)
return s;
break;
case ProjectSceneInstance::Type_Scene2d:
if (s->instance_2d->name == name)
return s;
break;
}
return NULL;
}
ProjectSceneInstance *Project::FindSceneInstance(const GS::S3D::Scene *scene) const
{
ListForeachPtr(ProjectSceneInstance *, s, instance_list)
if (s->instance_3d == scene)
return s;
return NULL;
}
ProjectSceneInstance *Project::FindSceneInstance(const GS::S2D::Scene *scene) const
{
ListForeachPtr(ProjectSceneInstance *, s, instance_list)
if (s->instance_2d == scene)
return s;
return NULL;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void Project::New()
{
Close();
name = "New Project";
root_script_list.Clear();
search_path.Clear();
}
bool Project::Open(bool project_exec_mode)
{
__PROJECT_ACTION_SAFETY_CHECK(false)
vm->Set("g_platform", Platform::Get().GetName().c_str());
vm->Set("g_context_project", project_exec_mode);
if (!CompileRootScripts())
return false;
if (!script_unit->Open())
return false;
return true;
}
bool Project::Setup()
{
__PROJECT_ACTION_SAFETY_CHECK(false)
// Script callback.
if (script_unit->SetupFunctionCall("OnSetup", script_unit->setup_callback))
script_unit->DoFunctionCall();
return true;
}
void Project::Close()
{
__PROJECT_ACTION_SAFETY_CHECK_RAW
// OnClose callback.
if (script_unit->SetupFunctionCall("OnClose"))
script_unit->DoFunctionCall(0);
// Drop content.
file_path.Clear();
// Drop all layer/instance/scene.
layer_list.Clear();
instance_list.Clear();
flags = 0;
script_unit->Close();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ProjectLayer *Project::AddLayer(ProjectSceneInstance *scene, float zorder)
{
ProjectLayer *layer = new ProjectLayer(scene, zorder);
if (!layer)
__ERR__(__LOG_E__ << "Failed to allocate a new project scene layer.\n", NULL)
layer_list.Add(layer);
return layer;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ProjectSceneInstance *Project::Instantiate(GS::S3D::Scene *scene)
{
ProjectSceneInstance *inst = new ProjectSceneInstance(scene);
if (inst)
instance_list.Add(inst);
return inst;
}
ProjectSceneInstance *Project::Instantiate(GS::S2D::Scene *scene)
{
ProjectSceneInstance *inst = new ProjectSceneInstance(scene);
if (inst)
instance_list.Add(inst);
return inst;
}
ProjectSceneInstance *Project::Instantiate(const char *name)
{
__PROJECT_ACTION_SAFETY_CHECK(NULL)
// Scene is already instantiated.
ProjectSceneInstance *inst = FindSceneInstance(name);
if (inst)
return inst;
// Create new instance.
NML::File file;
if (!NML::Parser::Load(name, file))
__ERR__(__LOG_E__ << "Could not instantiate scene '" << name << "', file not found.\n", NULL)
// Scene 3d
if (file.GetTag("Scene;"))
{
S3D::Scene *scene = new S3D::Scene(vm);
if (!scene)
__ERR__(__LOG_E__ << " Failed to allocate scene object.\n", NULL)
scene->SetClock(clock);
if ((inst = new ProjectSceneInstance(scene)) == NULL)
{
_safe_delete(scene);
__ERR__(__LOG_E__ << " Failed to allocate project scene instance.\n", NULL)
}
scene->Create(iproject_factory->NewPhysicWorld());
NML::LoadFromFile(*scene, file);
scene->name = name;
scene->InstanceSetup();
scene->RenderSetup(factories);
scene->SetAsScriptGlobalScene();
scene->Setup(NoTool);
scene->Reset();
}
else if (file.GetTag("UIScene;"))
{
S2D::Scene *scene = new S2D::Scene(vm);
if (!scene)
__ERR__(__LOG_E__ << " Failed to allocate scene 2D object.\n", NULL)
scene->SetClock(clock);
if ((inst = new ProjectSceneInstance(scene)) == NULL)
{
_safe_delete(scene);
__ERR__(__LOG_E__ << " Failed to allocate project scene instance.\n", NULL)
}
NML::LoadFromFile(*scene, file);
scene->name = name;
scene->RenderSetup(factories);
scene->SetAsScriptGlobalScene();
scene->Setup();
scene->Reset();
}
if (inst)
instance_list.Append(inst);
return inst;
}
void Project::Delete(ProjectSceneInstance *inst)
{
__PROJECT_ACTION_SAFETY_CHECK_RAW
if (!inst)
return;
// Callback.
if (script_unit->SetupFunctionCall("OnUnloadScene"))
{
script_unit->PushFunctionCallArgument(Script::Variant((void *)inst, Script::typetag_ProjectScene));
script_unit->DoFunctionCall(0);
}
// Drop scene from all layers using it.
ListForeachPtr(ProjectLayer *, layer, layer_list)
if (layer->inst == inst)
layer_list.Remove(layer);
instance_list.Remove(inst);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
Project::Project(ResourceFactories *f, GS::IFontFactory *ff, GS::Script::IVM *_vm) : vm(_vm)
{
factories = f;
name = "New Project";
authors = "Authors";
description = "New project";
company = "Empty Notice";
clock = new Clock;
font_cache = new FontCache(ff);
font_cache->LoadFont("@core/default.ttf");
script_unit = new ProjectScriptUnit(vm);
script_unit->SetInterfaceObject(this, Script::typetag_Project);
prohibit_project_action = false;
}
Project::~Project()
{
Close();
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,78 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "metafile/nml.h"
#include "log/log.h"
using namespace GS::Core;
using GS::NML::Tag;
//------------------------------------------------------------------------------
bool Project::FromMetaTag(Tag &tag)
{
if (tag.name != "Environment")
__ERR__(__LOG_E__ << "Could not parse project, incorrect root tag (" << tag.name << ").\n", false)
name.Clear();
search_path.Clear();
root_script_list.Clear();
NMLTagForeach(t, tag)
{
if (t->name == "Name") name = t->GetString();
else if (t->name == "Authors") authors = t->GetString();
else if (t->name == "Description") description = t->GetString();
else if (t->name == "Copyright") company = t->GetString();
else if (t->name == "Company") company = t->GetString();
else if (t->name == "Include")
{
NMLTagForeach(st, *t)
if (st->name == "URI")
root_script_list.Add(st->GetString());
}
else if (t->name == "SearchPaths")
{
NMLTagForeach(path, *t)
if (path->GetType() == GS::Variant::VariantString)
search_path.Add(path->GetString());
}
else if (t->name == "ScriptUnit")
script_unit->FromMetaTag(*t);
}
return true;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
Tag *Project::AsMetaTag() const
{
Tag *root = new Tag("Environment");
if (!root)
__ERR__(__LOG_E__ << "Could not create project root tag to serialize.\n", NULL)
root->AddChild("Name", name.c_str());
root->AddChild("Authors", authors.c_str());
root->AddChild("Description", description.c_str());
root->AddChild("Company", company.c_str());
root->AddChild(script_unit->AsMetaTag());
// Save includes.
if (Tag *include_tag = root->AddChild("Include"))
for (uint n = 0; n < root_script_list.GetCount(); ++n)
include_tag->AddChild("URI", root_script_list.ObjectAt(n).c_str());
// Save search paths.
if (Tag *path_section = root->AddChild("SearchPaths"))
for (uint n = 0; n < search_path.GetCount(); ++n)
path_section->AddChild("Path", search_path.ObjectAt(n).c_str());
return root;
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,59 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "scene3d/scene.h"
#include "ui/ui.h"
#include "core/renderer.h"
using namespace GS::Core;
using namespace GS::Render;
//------------------------------------------------------------------------------
void Project::DrawProfilerText(Renderer &render, RasterFont *font[2], float &x, float &y)
{
render.SetWorldMatrix(Matrix4::IdentityMatrix(), &Matrix4::IdentityMatrix());
render.SetViewMatrix(Matrix4::IdentityMatrix(), &Matrix4::IdentityMatrix());
render.SetProjectionMatrix(Matrix4::IdentityMatrix());
Color title_color(1, 0.8f, 0);
Renderer::WriterConfig config(false);
// Output layer stack.
render.Write(*font[1], String::Format("Scene list (%d instantiated, %d active):\n\n", GetInstanceCount(), GetActiveCount()), x, y, config, 1, &title_color);
render.Write(*font[1], "Layer stack:", x, y, config, 1, &Color::White);
for (uint n = layer_list.GetCount(); n > 0; --n)
{
ProjectLayer *layer = layer_list.ObjectAt(n - 1);
render.Write(*font[0], String::Format(" -> %s\n", layer->inst ? layer->inst->GetPath().c_str() : "No Instance"), x, y, config, 1, &title_color);
}
render.Write(*font[0], "\n", x, y, config);
// Output scene details.
x += 16;
ListForeachPtr(ProjectSceneInstance *, inst, instance_list)
if (IsActive(*inst))
{
render.Write(*font[0], String::Format("Scene instance '%s':\n\n", inst->GetPath().c_str()), x, y, config, 1, &Color::White);
switch (inst->GetType())
{
case ProjectSceneInstance::Type_Scene2d:
inst->instance_2d->DrawProfilerText(render, font, x, y);
break;
case ProjectSceneInstance::Type_Scene3d:
inst->instance_3d->DrawProfilerText(render, font, x, y);
break;
}
}
x -= 16;
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,121 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "scene3d/scene.h"
#include "ui/ui.h"
#include "core/renderer.h"
#include "script/script_engine_types.h"
#include "script/script_variant.h"
using namespace GS::Core;
using namespace GS::Script;
static float CompareLayerZOrder(const ProjectLayer *c, const ProjectLayer *n) { return c->zorder - n->zorder; }
//------------------------------------------------------------------------------
void Project::Render(Renderer &renderer, RenderFlag render_flag)
{
__PROJECT_ACTION_SAFETY_CHECK_RAW
bool send_events = render_flag & FlagDisableScript ? false : true;
// Sort the layer list.
layer_list.Sort(CompareLayerZOrder);
// OnRender callback.
if (script_unit->SetupFunctionCall("OnRender"))
script_unit->DoFunctionCall();
// Render the layer display list.
int active_layer = 0;
ListForeachPtr(ProjectLayer *, layer, layer_list)
if (layer->inst && IsActive(*layer->inst))
{
// OnRenderScene callback.
if (send_events && script_unit->SetupFunctionCall("OnRenderScene"))
{
switch (layer->inst->GetType())
{
case ProjectSceneInstance::Type_Scene2d:
script_unit->PushFunctionCallArgument(Script::Variant(layer->inst->instance, typetag_Scene2d));
break;
case ProjectSceneInstance::Type_Scene3d:
script_unit->PushFunctionCallArgument(Script::Variant(layer->inst->instance, typetag_Scene3d));
break;
}
script_unit->PushFunctionCallArgument(Script::Variant(layer, typetag_ProjectLayer));
script_unit->DoFunctionCall();
}
// Specialized rendering.
prohibit_project_action = true;
switch (layer->inst->GetType())
{
case ProjectSceneInstance::Type_Scene2d:
{
GS::S2D::Scene *scene = layer->inst->instance_2d;
if (active_layer == 0)
renderer.Clear(0, 0, 0);
scene->Render(renderer);
}
break;
case ProjectSceneInstance::Type_Scene3d:
{
GS::S3D::Scene *scene = layer->inst->instance_3d;
scene->flags.Raise(S3D::Scene::FlagDebugPhysics, flags.IsSet(ProjectFlagDebugPhysics)); // synchronize scene flag with project one
scene->Render(renderer);
scene->RenderUI(renderer);
}
break;
}
prohibit_project_action = false;
++active_layer;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void Project::Update(uint eval_flag)
{
__PROJECT_ACTION_SAFETY_CHECK_RAW
// OnUpdate callback.
if (script_unit->SetupFunctionCall("OnUpdate", script_unit->update_callback))
script_unit->DoFunctionCall();
// Evaluate all instantiated scenes.
prohibit_project_action = true;
ListForeachPtr(ProjectSceneInstance *, inst, instance_list)
if (IsActive(*inst))
switch (inst->GetType())
{
case ProjectSceneInstance::Type_Scene2d:
if (inst->instance_2d)
inst->instance_2d->Update();
break;
case ProjectSceneInstance::Type_Scene3d:
if (inst->instance_3d)
{
inst->instance_3d->SetAsScriptGlobalScene();
inst->instance_3d->Update(eval_flag);
}
break;
}
prohibit_project_action = false;
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "scene3d/scene.h"
#include "ui/ui.h"
#include "script/script_engine_types.h"
#include "script/script_variant.h"
using namespace GS::Core;
//------------------------------------------------------------------------------
void Project::Activate(ProjectSceneInstance &inst, bool activate)
{
// Callback to project.
if (script_unit->SetupFunctionCall("OnActivateScene"))
{
script_unit->PushFunctionCallArgument(Script::Variant(&inst, Script::typetag_ProjectScene));
script_unit->DoFunctionCall();
}
// Set flag.
inst.active = activate;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
GS::String ProjectSceneInstance::GetPath() const
{
if (instance)
switch (GetType())
{
case Type_Scene2d: return instance_2d->name; break;
case Type_Scene3d: return instance_3d->name; break;
}
return "Empty";
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void ProjectSceneInstance::Free()
{
if (instance_2d)
{
instance_2d->SetAsScriptGlobalScene();
_safe_delete(instance_2d);
}
if (instance_3d)
{
instance_3d->SetAsScriptGlobalScene();
_safe_delete(instance_3d);
}
}
ProjectSceneInstance::~ProjectSceneInstance()
{
Free();
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project.h"
#include "script/script_variant.h"
#include "script/script_vm.h"
using namespace GS::Core;
//------------------------------------------------------------------------------
void Project::UpdateScriptClock()
{
vm->Set("g_dt_frame", clock->GetDeltaf());
vm->Set("g_clock", (float)clock->Get());
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool Project::CompileRootScripts()
{
if (!vm)
return false;
ListForeach(String, p, root_script_list)
if (!vm->CompileFile(p.Object()))
return false;
return true;
}
//------------------------------------------------------------------------------

View File

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "project/project_script_unit.h"
using namespace GS::Core;
//------------------------------------------------------------------------------
bool ProjectScriptUnit::Open()
{
if (!Unit::Open())
return false;
setup_callback = vm->GetObjectFromName("OnSetup", self);
update_callback = vm->GetObjectFromName("OnUpdate", self);
return true;
}
void ProjectScriptUnit::Close()
{
setup_callback = NULL;
update_callback = NULL;
Unit::Close();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ProjectScriptUnit::ProjectScriptUnit(GS::Script::IVM *vm) : Script::Unit(vm) {}
ProjectScriptUnit::~ProjectScriptUnit() { Close(); }
//------------------------------------------------------------------------------