mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
make story editor build
This commit is contained in:
parent
a42fdc81ea
commit
51eac85360
23 changed files with 201 additions and 136 deletions
|
|
@ -56,7 +56,7 @@ public:
|
||||||
virtual uint32_t GetRegister(int reg) = 0;
|
virtual uint32_t GetRegister(int reg) = 0;
|
||||||
|
|
||||||
// Variables management
|
// Variables management
|
||||||
virtual void ScanVariable(const std::function<void(Variable& element)>& operation) = 0;
|
virtual void ScanVariable(const std::function<void(std::shared_ptr<Variable> element)>& operation) = 0;
|
||||||
virtual void AddVariable() = 0;
|
virtual void AddVariable() = 0;
|
||||||
virtual void DeleteVariable(int i) = 0;
|
virtual void DeleteVariable(int i) = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ public:
|
||||||
ALL_CHARSETS = CHARSET_ALPHABET_LOWER | CHARSET_ALPHABET_UPPER |CHARSET_NUMBERS | CHARSET_SIGNS
|
ALL_CHARSETS = CHARSET_ALPHABET_LOWER | CHARSET_ALPHABET_UPPER |CHARSET_NUMBERS | CHARSET_SIGNS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int NameMaxSize = 32; // Max size for the variable name
|
||||||
|
|
||||||
Variable() {
|
Variable() {
|
||||||
m_uuid = Uuid().String();
|
m_uuid = Uuid().String();
|
||||||
m_label = Variable::GenerateRandomString(10, Variable::CHARSET_ALPHABET_LOWER | Variable::CHARSET_ALPHABET_UPPER );
|
m_label = Variable::GenerateRandomString(10, Variable::CHARSET_ALPHABET_LOWER | Variable::CHARSET_ALPHABET_UPPER );
|
||||||
|
|
@ -99,6 +101,10 @@ public:
|
||||||
m_valueType = ValueType::BOOL;
|
m_valueType = ValueType::BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetScalePower(int scalePower) {
|
||||||
|
m_scalePower = scalePower;
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string GetVariableName() const {
|
std::string GetVariableName() const {
|
||||||
return m_variableName;
|
return m_variableName;
|
||||||
|
|
@ -125,12 +131,45 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetStringValue() const {
|
||||||
|
return GetValue<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetIntegerValue() const {
|
||||||
|
return GetValue<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetFloatValue() const {
|
||||||
|
return GetValue<float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetBoolValue() const {
|
||||||
|
return GetValue<bool>();
|
||||||
|
}
|
||||||
|
|
||||||
using VariableValue = std::variant<int, float, bool, std::string>;
|
using VariableValue = std::variant<int, float, bool, std::string>;
|
||||||
|
|
||||||
std::string GetUuid() const {
|
std::string GetUuid() const {
|
||||||
return m_uuid;
|
return m_uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsString() const {
|
||||||
|
return m_valueType == ValueType::STRING;
|
||||||
|
}
|
||||||
|
bool IsInteger() const {
|
||||||
|
return m_valueType == ValueType::INTEGER;
|
||||||
|
}
|
||||||
|
bool IsFloat() const {
|
||||||
|
return m_valueType == ValueType::FLOAT;
|
||||||
|
}
|
||||||
|
bool IsBool() const {
|
||||||
|
return m_valueType == ValueType::BOOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetScalePower() const {
|
||||||
|
return m_scalePower;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string GenerateRandomString(size_t length, uint32_t flags)
|
static std::string GenerateRandomString(size_t length, uint32_t flags)
|
||||||
{
|
{
|
||||||
std::string charset = "";
|
std::string charset = "";
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ public:
|
||||||
MediaNode(const std::string &type);
|
MediaNode(const std::string &type);
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override;
|
|
||||||
virtual std::string GenerateConstants(IStoryPage &page, IStoryProject &project, int nb_out_conns) override;
|
|
||||||
|
|
||||||
void SetImage(const std::string &image);
|
void SetImage(const std::string &image);
|
||||||
std::string_view GetImage() const;
|
std::string_view GetImage() const;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ public:
|
||||||
static std::string GetEntryLabel(const std::string &id);
|
static std::string GetEntryLabel(const std::string &id);
|
||||||
|
|
||||||
virtual void Initialize() = 0;
|
virtual void Initialize() = 0;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) = 0;
|
|
||||||
|
|
||||||
void SetPosition(float x, float y);
|
void SetPosition(float x, float y);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,30 +16,3 @@ void BranchNode::Initialize()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string BranchNode::Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
|
|
||||||
std::list<std::shared_ptr<Connection>> conns;
|
|
||||||
page.GetNodeConnections(conns, GetId());
|
|
||||||
int i = 0;
|
|
||||||
std::list<std::shared_ptr<Connection>>::iterator c = conns.begin();
|
|
||||||
|
|
||||||
if (conns.size() == 2)
|
|
||||||
{
|
|
||||||
ss << R"(; ---------------------------- )"
|
|
||||||
<< GetTitle()
|
|
||||||
<< " Type: Branch"
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
ss << "eq r0, r0, r1\n"
|
|
||||||
<< "skipz r0\n"
|
|
||||||
<< "jump " << BaseNode::GetEntryLabel((*c)->inNodeId);
|
|
||||||
++c;
|
|
||||||
ss << "jump " << BaseNode::GetEntryLabel((*c)->inNodeId);
|
|
||||||
}
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public:
|
||||||
BranchNode(const std::string &type);
|
BranchNode(const std::string &type);
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,56 +16,3 @@ void CompareNode::Initialize()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string CompareNode::Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
|
|
||||||
std::list<std::shared_ptr<Connection>> conns;
|
|
||||||
page.GetNodeConnections(conns, GetId());
|
|
||||||
int i = 0;
|
|
||||||
std::list<std::shared_ptr<Connection>>::iterator c = conns.begin();
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
; Déclaration des variables en RAM
|
|
||||||
$var1 DV32 1 ; Première variable à comparer
|
|
||||||
$var2 DV32 1 ; Deuxième variable à comparer
|
|
||||||
|
|
||||||
; Code principal
|
|
||||||
.compare_ge:
|
|
||||||
; Charger les valeurs des variables dans les registres
|
|
||||||
lcons r1, $var1
|
|
||||||
load r1, @r1, 4 ; Charger 4 bytes (32 bits) de var1 dans r1
|
|
||||||
lcons r2, $var2
|
|
||||||
load r2, @r2, 4 ; Charger 4 bytes (32 bits) de var2 dans r2
|
|
||||||
|
|
||||||
; Comparer r1 >= r2
|
|
||||||
gt r3, r1, r2 ; r3 = 1 si r1 > r2, sinon 0
|
|
||||||
eq r4, r1, r2 ; r4 = 1 si r1 == r2, sinon 0
|
|
||||||
or r0, r3, r4 ; r0 = 1 si r1 > r2 OU r1 == r2, sinon 0
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if (conns.size() == 2)
|
|
||||||
{
|
|
||||||
ss << R"(; ---------------------------- )"
|
|
||||||
<< GetTitle()
|
|
||||||
<< " Type: Branch"
|
|
||||||
<< "\n";
|
|
||||||
|
|
||||||
ss << "eq r0, r0, r1\n"
|
|
||||||
<< "skipz r0\n"
|
|
||||||
<< "jump " << BaseNode::GetEntryLabel((*c)->inNodeId);
|
|
||||||
++c;
|
|
||||||
ss << "jump " << BaseNode::GetEntryLabel((*c)->inNodeId);
|
|
||||||
}
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public:
|
||||||
CompareNode(const std::string &type);
|
CompareNode(const std::string &type);
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,3 @@ void FunctionNode::Initialize()
|
||||||
// m_sound = j["sound"].get<std::string>();
|
// m_sound = j["sound"].get<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FunctionNode::Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns)
|
|
||||||
{
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public:
|
||||||
FunctionNode(const std::string &type);
|
FunctionNode(const std::string &type);
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override;
|
|
||||||
|
|
||||||
void StoreInternalData();
|
void StoreInternalData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,5 @@ void VariableNode::Initialize()
|
||||||
// m_sound = j["sound"].get<std::string>();
|
// m_sound = j["sound"].get<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VariableNode::Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns)
|
|
||||||
{
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ public:
|
||||||
VariableNode(const std::string &type = "variable-node");
|
VariableNode(const std::string &type = "variable-node");
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual std::string Build(IStoryPage &page, const StoryOptions &options, int nb_out_conns) override;
|
|
||||||
|
|
||||||
void StoreInternalData();
|
void StoreInternalData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ public:
|
||||||
// code << n->GenerateConstants(*this, project, OutputsCount(n->GetId())) << "\n";
|
// code << n->GenerateConstants(*this, project, OutputsCount(n->GetId())) << "\n";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
for (const auto & n : m_nodes)
|
// for (const auto & n : m_nodes)
|
||||||
{
|
// {
|
||||||
code << n->Build(*this, project.GetOptions(), OutputsCount(n->GetId())) << "\n";
|
// code << n->Build(*this, project.GetOptions(), OutputsCount(n->GetId())) << "\n";
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void GetNodeConnections(std::list<std::shared_ptr<Connection>> &c, const std::string &nodeId) override
|
virtual void GetNodeConnections(std::list<std::shared_ptr<Connection>> &c, const std::string &nodeId) override
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "story_project.h"
|
#include "story_project.h"
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
#include "media_node.h"
|
// #include "media_node.h"
|
||||||
#include "function_node.h"
|
#include "function_node.h"
|
||||||
#include "variable_node.h"
|
#include "variable_node.h"
|
||||||
#include "sys_lib.h"
|
#include "sys_lib.h"
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
StoryProject::StoryProject(ILogger &log)
|
StoryProject::StoryProject(ILogger &log)
|
||||||
: m_log(log)
|
: m_log(log)
|
||||||
{
|
{
|
||||||
registerNode<MediaNode>("media-node");
|
// registerNode<MediaNode>("media-node");
|
||||||
registerNode<FunctionNode>("function-node");
|
registerNode<FunctionNode>("function-node");
|
||||||
registerNode<VariableNode>("variable-node");
|
registerNode<VariableNode>("variable-node");
|
||||||
}
|
}
|
||||||
|
|
@ -223,7 +223,7 @@ std::pair<std::list<std::shared_ptr<Connection>>::iterator, std::list<std::share
|
||||||
return std::pair<std::list<std::shared_ptr<Connection>>::iterator, std::list<std::shared_ptr<Connection>>::iterator>();
|
return std::pair<std::list<std::shared_ptr<Connection>>::iterator, std::list<std::shared_ptr<Connection>>::iterator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoryProject::ScanVariable(const std::function<void(Variable& element)>& operation)
|
void StoryProject::ScanVariable(const std::function<void(std::shared_ptr<Variable> element)>& operation)
|
||||||
{
|
{
|
||||||
for (auto &v : m_variables)
|
for (auto &v : m_variables)
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,13 @@ void StoryProject::ScanVariable(const std::function<void(Variable& element)>& op
|
||||||
|
|
||||||
void StoryProject::AddVariable()
|
void StoryProject::AddVariable()
|
||||||
{
|
{
|
||||||
m_variables.push_back(Variable("var_" + std::to_string(m_variables.size()), "int32_t", 0, 8));
|
auto v = std::make_shared<Variable>("var_" + std::to_string(m_variables.size()));
|
||||||
|
|
||||||
|
v->SetValue(0);
|
||||||
|
v->SetValueType(Variable::ValueType::INTEGER);
|
||||||
|
v->SetConstant(false);
|
||||||
|
|
||||||
|
m_variables.push_back(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoryProject::DeleteVariable(int i)
|
void StoryProject::DeleteVariable(int i)
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public:
|
||||||
std::pair<std::list<std::shared_ptr<Connection>>::iterator, std::list<std::shared_ptr<Connection>>::iterator> Links(const std::string_view &page_uuid);
|
std::pair<std::list<std::shared_ptr<Connection>>::iterator, std::list<std::shared_ptr<Connection>>::iterator> Links(const std::string_view &page_uuid);
|
||||||
|
|
||||||
|
|
||||||
void ScanVariable(const std::function<void(Variable& element)>& operation);
|
void ScanVariable(const std::function<void(std::shared_ptr<Variable> element)>& operation);
|
||||||
void AddVariable();
|
void AddVariable();
|
||||||
void DeleteVariable(int i);
|
void DeleteVariable(int i);
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ private:
|
||||||
|
|
||||||
std::list<std::shared_ptr<StoryPage>> m_pages;
|
std::list<std::shared_ptr<StoryPage>> m_pages;
|
||||||
|
|
||||||
std::vector<Variable> m_variables;
|
std::vector<std::shared_ptr<Variable>> m_variables;
|
||||||
|
|
||||||
StoryOptions m_storyOptions;
|
StoryOptions m_storyOptions;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ set(SRCS
|
||||||
src/windows/cpu_window.cpp
|
src/windows/cpu_window.cpp
|
||||||
src/windows/variables_window.cpp
|
src/windows/variables_window.cpp
|
||||||
|
|
||||||
src/node_editor/media_node_widget.cpp
|
# src/node_editor/media_node_widget.cpp
|
||||||
src/node_editor/base_node_widget.cpp
|
src/node_editor/base_node_widget.cpp
|
||||||
src/node_editor/node_editor_window.cpp
|
src/node_editor/node_editor_window.cpp
|
||||||
src/node_editor/function_node_widget.cpp
|
src/node_editor/function_node_widget.cpp
|
||||||
|
|
@ -168,16 +168,17 @@ set(SRCS
|
||||||
|
|
||||||
|
|
||||||
# Core engine files
|
# Core engine files
|
||||||
../core/story-manager/src/compiler.cpp
|
|
||||||
../core/story-manager/src/story_project.cpp
|
../core/story-manager/src/story_project.cpp
|
||||||
../core/story-manager/src/story_page.cpp
|
../core/story-manager/src/story_page.cpp
|
||||||
../core/story-manager/src/base_node.cpp
|
|
||||||
../core/story-manager/src/media_node.cpp
|
|
||||||
../core/story-manager/src/compare_node.cpp
|
../core/story-manager/src/nodes/base_node.cpp
|
||||||
../core/story-manager/src/branch_node.cpp
|
../core/story-manager/src/nodes/compare_node.cpp
|
||||||
../core/story-manager/src/variable_node.cpp
|
../core/story-manager/src/nodes/branch_node.cpp
|
||||||
../core/story-manager/src/function_node.cpp
|
../core/story-manager/src/nodes/variable_node.cpp
|
||||||
../core/story-manager/src/connection.cpp
|
../core/story-manager/src/nodes/function_node.cpp
|
||||||
|
../core/story-manager/src/nodes/connection.cpp
|
||||||
|
|
||||||
../core/story-manager/lib/sys_lib.cpp
|
../core/story-manager/lib/sys_lib.cpp
|
||||||
../core/story-manager/lib/resource.cpp
|
../core/story-manager/lib/resource.cpp
|
||||||
|
|
||||||
|
|
@ -222,6 +223,8 @@ target_include_directories(${STORY_EDITOR_PROJECT} PUBLIC
|
||||||
../core/chip32
|
../core/chip32
|
||||||
../shared
|
../shared
|
||||||
../core/story-manager/src
|
../core/story-manager/src
|
||||||
|
../core/story-manager/src/nodes
|
||||||
|
../core/story-manager/src/compiler
|
||||||
../core/story-manager/lib
|
../core/story-manager/lib
|
||||||
../core/story-manager/interfaces
|
../core/story-manager/interfaces
|
||||||
)
|
)
|
||||||
|
|
|
||||||
105
story-editor/imgui.ini
Normal file
105
story-editor/imgui.ini
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
[Window][WindowOverViewport_11111111]
|
||||||
|
Pos=60,26
|
||||||
|
Size=1220,694
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Library Manager]
|
||||||
|
Pos=672,26
|
||||||
|
Size=608,694
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
[Window][Console]
|
||||||
|
Pos=386,659
|
||||||
|
Size=1152,344
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Emulator]
|
||||||
|
Pos=269,26
|
||||||
|
Size=401,694
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000005,1
|
||||||
|
|
||||||
|
[Window][Code viewer]
|
||||||
|
Pos=269,26
|
||||||
|
Size=401,694
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000005,0
|
||||||
|
|
||||||
|
[Window][Resources]
|
||||||
|
Pos=672,26
|
||||||
|
Size=608,694
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,1
|
||||||
|
|
||||||
|
[Window][Node editor]
|
||||||
|
Pos=96,129
|
||||||
|
Size=394,407
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][TOOLBAR]
|
||||||
|
Pos=96,105
|
||||||
|
Size=79,42
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Variables]
|
||||||
|
Pos=199,187
|
||||||
|
Size=121,72
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][CPU]
|
||||||
|
Pos=515,59
|
||||||
|
Size=626,744
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][RAM view]
|
||||||
|
Pos=378,79
|
||||||
|
Size=738,442
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Properties]
|
||||||
|
Pos=754,344
|
||||||
|
Size=626,744
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][ToolBar]
|
||||||
|
Pos=0,26
|
||||||
|
Size=60,694
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][QuitConfirm]
|
||||||
|
Pos=479,312
|
||||||
|
Size=321,96
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Table][0x7728942D,5]
|
||||||
|
RefScale=20
|
||||||
|
Column 0 Width=44 Sort=0v
|
||||||
|
Column 1 Width=72
|
||||||
|
Column 2 Width=104
|
||||||
|
Column 3 Width=54
|
||||||
|
Column 4 Width=75
|
||||||
|
|
||||||
|
[Table][0x69D69F59,2]
|
||||||
|
RefScale=20
|
||||||
|
Column 0 Width=22 Sort=0v
|
||||||
|
Column 1 Width=68
|
||||||
|
|
||||||
|
[Table][0x30BF8F98,3]
|
||||||
|
RefScale=20
|
||||||
|
Column 0 Width=259 Sort=0v
|
||||||
|
Column 1 Width=88
|
||||||
|
Column 2 Width=124
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,694 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x08BD597D SizeRef=610,694 Split=X
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=397,600 CentralNode=1 Selected=0x63869CAF
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=401,600 Selected=0x4B07C626
|
||||||
|
DockNode ID=0x00000002 Parent=0x08BD597D SizeRef=608,694 Selected=0x30401527
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#include "i_story_project.h"
|
#include "i_story_project.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include <imgui_node_editor.h>
|
#include <imgui_node_editor.h>
|
||||||
#include "media_node.h"
|
|
||||||
|
|
||||||
class FunctionNodeWidget : public BaseNodeWidget
|
class FunctionNodeWidget : public BaseNodeWidget
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ NodeEditorWindow::NodeEditorWindow(IStoryManager &manager)
|
||||||
, m_manager(manager)
|
, m_manager(manager)
|
||||||
{
|
{
|
||||||
|
|
||||||
registerNode<MediaNodeWidget>("media-node");
|
// registerNode<MediaNodeWidget>("media-node");
|
||||||
registerNode<FunctionNodeWidget>("function-node");
|
registerNode<FunctionNodeWidget>("function-node");
|
||||||
registerNode<VariableNodeWidget>("variable-node");
|
registerNode<VariableNodeWidget>("variable-node");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,16 @@ void VariableNodeWidget::DrawProperties()
|
||||||
if (ImGui::BeginCombo("Variables list", m_selectedVariable.c_str(), flags))
|
if (ImGui::BeginCombo("Variables list", m_selectedVariable.c_str(), flags))
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
m_manager.ScanVariable([&i, this] (Variable &var) {
|
m_manager.ScanVariable([&i, this] (std::shared_ptr<Variable> var) {
|
||||||
|
|
||||||
// ImGui::PushID(static_cast<int>(i)); // Assure l'unicité des widgets
|
// ImGui::PushID(static_cast<int>(i)); // Assure l'unicité des widgets
|
||||||
|
|
||||||
const bool is_selected = (m_selectedIndex == i);
|
const bool is_selected = (m_selectedIndex == i);
|
||||||
if (ImGui::Selectable(var.name.c_str(), is_selected))
|
std::string l = var->GetVariableName();
|
||||||
|
if (ImGui::Selectable(l.c_str(), is_selected))
|
||||||
{
|
{
|
||||||
m_selectedIndex = i;
|
m_selectedIndex = i;
|
||||||
m_selectedVariable = var.name;
|
m_selectedVariable = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
||||||
|
|
|
||||||
|
|
@ -1096,7 +1096,7 @@ uint32_t MainWindow::GetRegister(int reg)
|
||||||
return regVal;
|
return regVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ScanVariable(const std::function<void(Variable& element)>& operation)
|
void MainWindow::ScanVariable(const std::function<void(std::shared_ptr<Variable> element)>& operation)
|
||||||
{
|
{
|
||||||
if (m_story)
|
if (m_story)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ private:
|
||||||
virtual uint32_t GetRegister(int reg) override;
|
virtual uint32_t GetRegister(int reg) override;
|
||||||
|
|
||||||
// Variable
|
// Variable
|
||||||
virtual void ScanVariable(const std::function<void(Variable& element)>& operation) override;
|
virtual void ScanVariable(const std::function<void(std::shared_ptr<Variable> element)>& operation) override;
|
||||||
virtual void AddVariable() override;
|
virtual void AddVariable() override;
|
||||||
virtual void DeleteVariable(int i);
|
virtual void DeleteVariable(int i);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,47 +42,52 @@ void VariablesWindow::ShowRAMEditor()
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
m_story.ScanVariable([&i, this] (Variable &var) {
|
m_story.ScanVariable([&i, this] (std::shared_ptr<Variable> var) {
|
||||||
|
|
||||||
ImGui::PushID(static_cast<int>(i)); // Assure l'unicité des widgets
|
ImGui::PushID(static_cast<int>(i)); // Assure l'unicité des widgets
|
||||||
if (ImGui::TreeNode((var.name + "###variable").c_str()))
|
std::string l = var->GetVariableName();
|
||||||
|
if (ImGui::TreeNode((l + "###variable").c_str()))
|
||||||
{
|
{
|
||||||
// Modifier le nom de la variable
|
// Modifier le nom de la variable
|
||||||
static char buffer[Variable::NameMaxSize];
|
static char buffer[Variable::NameMaxSize];
|
||||||
std::strncpy(buffer, var.name.c_str(), sizeof(buffer));
|
std::strncpy(buffer, l.c_str(), sizeof(buffer));
|
||||||
buffer[sizeof(buffer) - 1] = '\0'; // Assure la terminaison
|
buffer[sizeof(buffer) - 1] = '\0'; // Assure la terminaison
|
||||||
if (ImGui::InputText("Name", buffer, sizeof(buffer))) {
|
if (ImGui::InputText("Name", buffer, sizeof(buffer))) {
|
||||||
var.name = buffer;
|
var->SetVariableName(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choisir le type de la variable
|
// Choisir le type de la variable
|
||||||
const char* types[] = {"Integer", "String"};
|
const char* types[] = {"Integer", "String"};
|
||||||
static int selectedType = (var.type == "Integer") ? 0 : 1;
|
static int selectedType = var->IsInteger() ? 0 : 1; // 0 for Integer, 1 for String
|
||||||
if (ImGui::Combo("Type", &selectedType, types, IM_ARRAYSIZE(types))) {
|
if (ImGui::Combo("Type", &selectedType, types, IM_ARRAYSIZE(types))) {
|
||||||
var.type = types[selectedType];
|
var->SetValueType(selectedType == 0 ? Variable::ValueType::INTEGER : Variable::ValueType::STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var.type == "Integer")
|
if (var->IsInteger())
|
||||||
{
|
{
|
||||||
// Modifier l'échelle
|
// Modifier l'échelle
|
||||||
ImGui::InputInt("Scale Power (10^x)", &var.scalePower);
|
int scalePower = var->GetScalePower();
|
||||||
|
if (ImGui::InputInt("Scale Power (10^x)", &scalePower))
|
||||||
|
{
|
||||||
|
var->SetScalePower(scalePower);
|
||||||
|
}
|
||||||
|
|
||||||
// Modifier la valeur entière
|
// Modifier la valeur entière
|
||||||
int intValue = static_cast<int>(var.value);
|
int intValue = static_cast<int>(var->GetIntegerValue());
|
||||||
if (ImGui::InputInt("Integer Value", &intValue)) {
|
if (ImGui::InputInt("Integer Value", &intValue)) {
|
||||||
var.value = static_cast<int64_t>(intValue);
|
var->SetIntegerValue(static_cast<int64_t>(intValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Afficher la valeur flottante calculée
|
// Afficher la valeur flottante calculée
|
||||||
float floatValue = ScaledToFloat(var.value, var.scalePower);
|
float floatValue = ScaledToFloat(var->GetIntegerValue(), var->GetScalePower());
|
||||||
ImGui::Text("Float Value: %.6f", floatValue);
|
ImGui::Text("Float Value: %.6f", floatValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::strncpy(buffer, var.valueText.c_str(), sizeof(buffer));
|
std::strncpy(buffer, var->GetStringValue().c_str(), sizeof(buffer));
|
||||||
if (ImGui::InputText("Text value", buffer, sizeof(buffer)))
|
if (ImGui::InputText("Text value", buffer, sizeof(buffer)))
|
||||||
{
|
{
|
||||||
var.valueText = buffer;
|
var->SetTextValue(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue