Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AngelScript improvements: ImGui, mouse position, script monitor UI + loadscript console command. #2931

Merged
merged 12 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
559 changes: 315 additions & 244 deletions doc/angelscript/Script2Game/GameScriptClass.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/scripts/races.as
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,12 @@ class racesManager {
}

if( this.raceList[this.currentRace].laps == this.LAPS_NoLaps )
game.UpdateDirectionArrow(this.raceList[this.currentRace].raceName+" checkpoint "+position+" / "+(this.raceList[this.currentRace].checkPointsCount-1), vector3(v[0], v[1], v[2]));
game.updateDirectionArrow(this.raceList[this.currentRace].raceName+" checkpoint "+position+" / "+(this.raceList[this.currentRace].checkPointsCount-1), vector3(v[0], v[1], v[2]));
else
{
if( position == 0 )
position = this.raceList[this.currentRace].checkPointsCount;
game.UpdateDirectionArrow(this.raceList[this.currentRace].raceName+" checkpoint "+position+" / "+(this.raceList[this.currentRace].checkPointsCount), vector3(v[0], v[1], v[2]));
game.updateDirectionArrow(this.raceList[this.currentRace].raceName+" checkpoint "+position+" / "+(this.raceList[this.currentRace].checkPointsCount), vector3(v[0], v[1], v[2]));
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static GUIManager* g_gui_manager;
static InputEngine* g_input_engine;
static CacheSystem* g_cache_system;
static MumbleIntegration* g_mumble;
static TerrainManager* g_sim_terrain;
static Terrain* g_sim_terrain;
static ThreadPool* g_thread_pool;
static CameraManager* g_camera_manager;
static GfxScene g_gfx_scene;
Expand Down Expand Up @@ -238,7 +238,7 @@ CVar* gfx_reduce_shadows;
CVar* gfx_enable_rtshaders;

// Instance management
void SetSimTerrain (TerrainManager* obj) { g_sim_terrain = obj;}
void SetSimTerrain (Terrain* obj) { g_sim_terrain = obj;}
void SetCacheSystem (CacheSystem* obj) { g_cache_system = obj; }

// Instance access
Expand All @@ -250,7 +250,7 @@ Console* GetConsole () { return &g_console;}
InputEngine* GetInputEngine () { return g_input_engine;}
CacheSystem* GetCacheSystem () { return g_cache_system;}
MumbleIntegration* GetMumble () { return g_mumble; }
TerrainManager* GetSimTerrain () { return g_sim_terrain; }
Terrain* GetSimTerrain () { return g_sim_terrain; }
ThreadPool* GetThreadPool () { return g_thread_pool; }
CameraManager* GetCameraManager () { return g_camera_manager; }
GfxScene* GetGfxScene () { return &g_gfx_scene; }
Expand Down
4 changes: 2 additions & 2 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ Console* GetConsole();
InputEngine* GetInputEngine();
CacheSystem* GetCacheSystem();
MumbleIntegration* GetMumble();
TerrainManager* GetSimTerrain();
Terrain* GetSimTerrain();
ThreadPool* GetThreadPool();
CameraManager* GetCameraManager();
GfxScene* GetGfxScene();
Expand All @@ -466,7 +466,7 @@ void CreateSoundScriptManager();
void CreateScriptEngine();

// Setters
void SetSimTerrain (TerrainManager* obj);
void SetSimTerrain (Terrain* obj);
void SetCacheSystem (CacheSystem* obj);

// Cleanups
Expand Down
24 changes: 14 additions & 10 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ set(SOURCE_FILES
gui/panels/GUI_MultiplayerClientList.{h,cpp}
gui/panels/GUI_NodeBeamUtils.{h,cpp}
gui/panels/GUI_SimActorStats.{h,cpp}
gui/panels/GUI_ScriptMonitor.{h,cpp}
gui/panels/GUI_SimPerfStats.{h,cpp}
gui/panels/GUI_SurveyMap.{h,cpp}
gui/panels/GUI_VehicleDescription.{h,cpp}
Expand Down Expand Up @@ -198,8 +199,8 @@ set(SOURCE_FILES
terrain/OgreTerrainPSSMMaterialGenerator.{h,cpp}
terrain/TerrainEditor.{h,cpp}
terrain/TerrainGeometryManager.{h,cpp}
terrain/TerrainManager.{h,cpp}
terrain/TerrainObjectManager.{h,cpp}
terrain/Terrain.{h,cpp}
terrain/TerrainObjectManager.{h,cpp}
threadpool/ThreadPool.h
utils/ConfigFile.{h,cpp}
utils/ErrorUtils.{h,cpp}
Expand All @@ -220,11 +221,18 @@ if (USE_ANGELSCRIPT)
list(APPEND SOURCE_FILES
scripting/GameScript.{h,cpp}
scripting/LocalStorage.{h,cpp}
scripting/OgreAngelscript.cpp
scripting/ImGuiAngelscript.cpp
scripting/InputEngineAngelscript.cpp
scripting/OgreScriptBuilder.{h,cpp}
scripting/ScriptEngine.{h,cpp}
scripting/bindings/AngelScriptBindings.h
scripting/bindings/ActorAngelscript.cpp
scripting/bindings/ConsoleAngelscript.cpp
scripting/bindings/GameScriptAngelscript.cpp
scripting/bindings/ImGuiAngelscript.cpp
scripting/bindings/InputEngineAngelscript.cpp
scripting/bindings/LocalStorageAngelscript.cpp
scripting/bindings/OgreAngelscript.cpp
scripting/bindings/ScriptEventsAngelscript.cpp
scripting/bindings/VehicleAiAngelscript.cpp
)
endif ()

Expand Down Expand Up @@ -310,7 +318,6 @@ target_include_directories(${BINNAME} PRIVATE
gfx/camera
gfx/hydrax
gfx/particle
gfx/procedural
gfx/skyx
gui
gui/imgui
Expand All @@ -321,8 +328,6 @@ target_include_directories(${BINNAME} PRIVATE
physics/air
physics/collision
physics/flex
physics/mplatform
physics/threading
physics/utils
physics/water
resources
Expand All @@ -333,9 +338,8 @@ target_include_directories(${BINNAME} PRIVATE
resources/terrn2_fileformat
resources/tobj_fileformat
system
rig_editor
rig_editor/rig_data
scripting
scripting/bindings
terrain
terrain/map
threadpool
Expand Down
2 changes: 1 addition & 1 deletion source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace RoR
class Task;
class TerrainEditor;
class TerrainGeometryManager;
class TerrainManager;
class Terrain;
class TerrainObjectManager;
struct Terrn2Author;
struct Terrn2Def;
Expand Down
4 changes: 2 additions & 2 deletions source/main/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "SkyManager.h"
#include "SkyXManager.h"
#include "SoundScriptManager.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "Utils.h"
#include "VehicleAI.h"
#include "GUI_VehicleButtons.h"
Expand Down Expand Up @@ -112,7 +112,7 @@ bool GameContext::LoadTerrain(std::string const& filename_part)
App::GetCacheSystem()->LoadResource(*terrn_entry);

// Perform the loading and setup
App::SetSimTerrain(TerrainManager::LoadAndPrepareTerrain(terrn_entry));
App::SetSimTerrain(RoR::Terrain::LoadAndPrepareTerrain(terrn_entry));
if (!App::GetSimTerrain())
{
return false; // Message box already displayed
Expand Down
2 changes: 1 addition & 1 deletion source/main/GameContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef std::queue < Message, std::list<Message>> GameMsgQueue;

/// Central game state manager.
/// RoR's gameplay is quite simple in structure, it consists of:
/// - static terrain: static elevation map, managed by `TerrainManager`.
/// - static terrain: static elevation map, managed by `Terrain`.
/// this includes static collision objects (or intrusion detection objects), managed by `TerrainObjectManager`.
/// - softbody actors: a.k.a "trucks" or "vehicles" (local or remote), managed by `ActorManager`. They collide with static terrain and each other.
/// this includes 'fixes' - actors with partially fixed position.
Expand Down
2 changes: 1 addition & 1 deletion source/main/gameplay/AutoPilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Application.h"
#include "SimData.h"
#include "SoundScriptManager.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "Water.h"

using namespace Ogre;
Expand Down
2 changes: 1 addition & 1 deletion source/main/gameplay/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "InputEngine.h"
#include "MovableText.h"
#include "Network.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "Utils.h"
#include "Water.h"

Expand Down
2 changes: 1 addition & 1 deletion source/main/gameplay/Landusemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "Console.h"
#include "ErrorUtils.h"
#include "Language.h"
#include "TerrainManager.h"
#include "Terrain.h"
#ifdef USE_PAGED
#include "PropertyMaps.h"
#include "PagedGeometry.h"
Expand Down
2 changes: 1 addition & 1 deletion source/main/gameplay/ProceduralRoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Application.h"
#include "Collisions.h"
#include "GfxScene.h"
#include "TerrainManager.h"
#include "Terrain.h"

using namespace Ogre;
using namespace RoR;
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/DustPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <Ogre.h>

#include "Application.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "Water.h"

using namespace Ogre;
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/EnvironmentMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "GfxActor.h"
#include "GfxScene.h"
#include "SkyManager.h"
#include "TerrainManager.h"
#include "Terrain.h"

#include <OgreOverlaySystem.h>
#include <OgreOverlayManager.h>
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/GfxActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "SlideNode.h"
#include "SkyManager.h"
#include "SoundScriptManager.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "TurboJet.h"
#include "TurboProp.h"
#include "Utils.h"
Expand Down
4 changes: 2 additions & 2 deletions source/main/gfx/GfxScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "SkyManager.h"
#include "SkyXManager.h"
#include "TerrainGeometryManager.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "TerrainObjectManager.h"
#include "Utils.h"

Expand Down Expand Up @@ -140,7 +140,7 @@ void GfxScene::UpdateScene(float dt_sec)
// Terrain - animated meshes and paged geometry
App::GetSimTerrain()->getObjectManager()->UpdateTerrainObjects(dt_sec);

// Terrain - lightmap; TODO: ported as-is from TerrainManager::update(), is it needed? ~ only_a_ptr, 05/2018
// Terrain - lightmap; TODO: ported as-is from Terrain::update(), is it needed? ~ only_a_ptr, 05/2018
App::GetSimTerrain()->getGeometryManager()->UpdateMainLightPosition(); // TODO: Is this necessary? I'm leaving it here just in case ~ only_a_ptr, 04/2017

// Terrain - water
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/HydraxWater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "CameraManager.h"
#include "GfxScene.h"
#include "SkyManager.h"
#include "TerrainManager.h"
#include "Terrain.h"

#ifdef USE_CAELUM
#include <Caelum.h>
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/SkyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "AppContext.h"
#include "CameraManager.h"
#include "GfxScene.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "TerrainGeometryManager.h"

#include <Caelum.h>
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/SkyXManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "CameraManager.h"
#include "GfxScene.h"
#include "HydraxWater.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "TerrainGeometryManager.h"

using namespace Ogre;
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/SurveyMapTextureCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Application.h"
#include "GfxScene.h"
#include "IWater.h"
#include "TerrainManager.h"
#include "Terrain.h"

using namespace Ogre;
using namespace RoR;
Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/Water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "CameraManager.h"
#include "GfxScene.h"
#include "PlatformUtils.h" // PathCombine
#include "TerrainManager.h"
#include "Terrain.h"

#include <Ogre.h>

Expand Down
2 changes: 1 addition & 1 deletion source/main/gfx/camera/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "Language.h"
#include "OverlayWrapper.h"
#include "Replay.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "GUIManager.h"
#include "PerVehicleCameraContext.h"
#include "Water.h"
Expand Down
2 changes: 1 addition & 1 deletion source/main/gui/GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "OverlayWrapper.h"
#include "PlatformUtils.h"
#include "RTTLayer.h"
#include "TerrainManager.h"
#include "Terrain.h"

#include <OgreOverlayElement.h>
#include <OgreOverlayContainer.h>
Expand Down
2 changes: 1 addition & 1 deletion source/main/gui/OverlayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "RoRVersion.h"
#include "ScrewProp.h"
#include "SoundScriptManager.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "TurboProp.h"
#include "Utils.h"

Expand Down
8 changes: 8 additions & 0 deletions source/main/gui/panels/GUI_ConsoleWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ void ConsoleWindow::Draw()
ImGui::Columns(1); // reset
ImGui::EndMenu();
}
ImGui::SetNextWindowSize(ImVec2(0.f, 0.f)); // reset to auto-fit

if (ImGui::BeginMenu(_LC("Console", "Script Monitor")))
{
ImGui::Dummy(ImVec2(340.f, 1.f)); // Manually resize width (DearIMGUI bug workaround)
m_script_monitor.Draw();
ImGui::EndMenu();
}
#endif
ImGui::EndMenuBar();
}
Expand Down
14 changes: 10 additions & 4 deletions source/main/gui/panels/GUI_ConsoleWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "GUI_ConsoleView.h"
#include "OgreImGui.h"
#include "GUI_AngelScriptExamples.h"
#include "GUI_ScriptMonitor.h"

#include <vector>
#include <string>
Expand All @@ -51,17 +52,22 @@ class ConsoleWindow

private:

AngelScriptExamples m_angelscript_examples;

static int TextEditCallback(ImGuiTextEditCallbackData *data);
void TextEditCallbackProc(ImGuiTextEditCallbackData *data);

// Window state
bool m_is_visible = false;
bool m_is_hovered = false;

// Special panels
AngelScriptExamples m_angelscript_examples;
ScriptMonitor m_script_monitor;

// Console context
ConsoleView m_console_view;
Str<500> m_cmd_buffer;
std::vector<std::string> m_cmd_history;
int m_cmd_history_cursor = -1;
bool m_is_visible = false;
bool m_is_hovered = false;
};

} // namespace GUI
Expand Down
2 changes: 1 addition & 1 deletion source/main/gui/panels/GUI_FrictionSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "GameContext.h"
#include "GUIManager.h"
#include "Language.h"
#include "TerrainManager.h"
#include "Terrain.h"
#include "Utils.h"

using namespace RoR;
Expand Down
Loading