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

Fixing and improving the Tuning menu. #3151

Merged
merged 19 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fae9af4
Tuning: fixed typo in 'protected' check for props.
ohlidalp Apr 12, 2024
9ba31a1
Tuning: corrected logs about processing tweaks from addonparts.
ohlidalp Apr 13, 2024
a358909
:bug: Fixed FlexbodyDebug UI 'hide other' not working for flexbodies.
ohlidalp Apr 13, 2024
f42d93f
Tuning: proof-of-concept addonpart conflict markers.
ohlidalp Apr 23, 2024
5bce711
Tuning: disabled for multiplayer.
ohlidalp Apr 23, 2024
2415688
Tuning: added :envelope: MSG_GUI_REFRESH_TUNING_MENU_REQUESTED
ohlidalp Apr 23, 2024
fba8ff1
Tuning: Finalized markers for conflicting addonparts.
ohlidalp Apr 23, 2024
9305f0f
Tuning: added `addonpart_filename` directive (optional whitelist)
ohlidalp Apr 24, 2024
4b6734b
Tuning: added flare Adding/Removing (not Tweaking yet)
ohlidalp Apr 26, 2024
92cb5af
Tuning: added exhausts removal (`_unwanted` or UI)
ohlidalp Apr 26, 2024
670f61b
:bug: Fixed GenericDoc discarding NAKED strings that start like bools.
ohlidalp Apr 27, 2024
31f3183
Tuning: fixed flares not loading material in addonpart ZIP.
ohlidalp Apr 27, 2024
dd273da
Tuning: fixed crash after saving tuneup (on menu reload)
ohlidalp Apr 27, 2024
e8313cc
Tuning: UI touch: right-aligned addonpart [Reload] buttons.
ohlidalp Apr 27, 2024
33259c7
Tuning: Removed redundant `_override_rg` mechanic.
ohlidalp May 9, 2024
7d0b118
Tuning: added managedmaterial tweaking.
ohlidalp May 7, 2024
ae9d738
Tuning: fixed loading flat files in root content-dirs.
ohlidalp May 27, 2024
14cffb5
Tuning: added matching tuneups by filename (on top of GUID)
ohlidalp May 26, 2024
fda6b28
Tuning: Fixed false positives in addonpart conflict check.
ohlidalp May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ enum MsgType
MSG_GUI_SHOW_MESSAGE_BOX_REQUESTED, //!< Payload = MessageBoxConfig* (owner)
MSG_GUI_DOWNLOAD_PROGRESS,
MSG_GUI_DOWNLOAD_FINISHED,
MSG_GUI_REFRESH_TUNING_MENU_REQUESTED,
// Editing
MSG_EDI_MODIFY_GROUNDMODEL_REQUESTED, //!< Payload = RoR::ground_model_t* (weak)
MSG_EDI_ENTER_TERRN_EDITOR_REQUESTED,
Expand Down
6 changes: 6 additions & 0 deletions source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ namespace RoR
typedef int FlexbodyID_t; //!< Index to `GfxActor::m_flexbodies`, `use RoR::FLEXBODYID_INVALID` as empty value
static const FlexbodyID_t FLEXBODYID_INVALID = -1;

typedef int FlareID_t; //!< Index into `Actor::ar_flares`, use `RoR::FLAREID_INVALID` as empty value
static const FlareID_t FLAREID_INVALID = -1;

typedef int ExhaustID_t; //!< Index into `Actor::exhausts`, use `RoR::EXHAUSTID_INVALID` as empty value
static const ExhaustID_t EXHAUSTID_INVALID = -1;

class Actor;
class ActorManager;
class ActorSpawner;
Expand Down
22 changes: 12 additions & 10 deletions source/main/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ ActorPtr GameContext::SpawnActor(ActorSpawnRequest& rq)
}
}

if (App::sim_tuning_enabled->getBool())
if (App::sim_tuning_enabled->getBool() && (App::mp_state->getEnum<MpState>() != MpState::CONNECTED))
{
if (rq.asr_tuneup_entry)
{
Expand Down Expand Up @@ -272,6 +272,7 @@ ActorPtr GameContext::SpawnActor(ActorSpawnRequest& rq)
#endif //SOCKETW

ActorPtr fresh_actor = m_actor_manager.CreateNewActor(rq, def);
bool fresh_actor_seat_player = false;

// lock slide nodes after spawning the actor?
if (def->slide_nodes_connect_instantly)
Expand All @@ -284,7 +285,7 @@ ActorPtr GameContext::SpawnActor(ActorSpawnRequest& rq)
m_last_spawned_actor = fresh_actor;
if (fresh_actor->ar_driveable != NOT_DRIVEABLE)
{
this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(fresh_actor))));
fresh_actor_seat_player = true;
}
if (rq.asr_spawnbox == nullptr)
{
Expand All @@ -298,13 +299,7 @@ ActorPtr GameContext::SpawnActor(ActorSpawnRequest& rq)
fresh_actor->ar_num_nodes > 0 &&
App::diag_preset_veh_enter->getBool())
{
this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(fresh_actor))));
}
if (fresh_actor->ar_driveable != NOT_DRIVEABLE &&
fresh_actor->ar_num_nodes > 0 &&
App::cli_preset_veh_enter->getBool())
{
this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(fresh_actor))));
fresh_actor_seat_player = true;
}
}
else if (rq.asr_origin == ActorSpawnRequest::Origin::TERRN_DEF)
Expand Down Expand Up @@ -347,10 +342,17 @@ ActorPtr GameContext::SpawnActor(ActorSpawnRequest& rq)
rq.asr_origin != ActorSpawnRequest::Origin::NETWORK &&
rq.asr_enter)
{
this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(fresh_actor))));
fresh_actor_seat_player = true;
}
}

if (fresh_actor_seat_player)
{
this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, new ActorPtr(fresh_actor)));
// Loading all addonparts to resolve conflicts is slow and would cause huge UI lag if not forced now. Do it right after player was seated in the actor.
this->ChainMessage(Message(MSG_GUI_REFRESH_TUNING_MENU_REQUESTED));
}

return fresh_actor;
}

Expand Down
13 changes: 9 additions & 4 deletions source/main/gfx/GfxActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3010,10 +3010,9 @@ void RoR::GfxActor::UpdateFlexbodies()

for (FlexBody* fb: m_flexbodies)
{
// Update visibility
fb->setVisible(
fb->getCameraMode() == CAMERA_MODE_ALWAYS_VISIBLE
|| fb->getCameraMode() == m_simbuf.simbuf_cur_cinecam);
// Update visibility (same logic as props)
const bool visible = (fb->fb_camera_mode_active == CAMERA_MODE_ALWAYS_VISIBLE || fb->fb_camera_mode_active == m_simbuf.simbuf_cur_cinecam);
fb->setVisible(visible);

// Update visible on background thread
if (fb->isVisible())
Expand Down Expand Up @@ -3086,6 +3085,12 @@ void RoR::GfxActor::UpdateFlares(float dt_sec, bool is_player)
for (int i=0; i<num_flares; ++i)
{
flare_t& flare = m_actor->ar_flares[i];

// Skip placeholder flares (removed via Tuning system)
if (!flare.bbs)
{
continue;
}

this->SetMaterialFlareOn(i, flare.intensity > 0.3);

Expand Down
15 changes: 9 additions & 6 deletions source/main/gfx/GfxData.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ enum class WheelSide: char
};

// Dynamic visibility control (value 0 and higher is cinecam index) - common to 'props' and 'flexbodies'
static const int CAMERA_MODE_ALWAYS_HIDDEN = -3;
static const int CAMERA_MODE_ALWAYS_VISIBLE = -2;
static const int CAMERA_MODE_3RDPERSON_ONLY = -1;
typedef int CameraMode_t;
static CameraMode_t CAMERA_MODE_ALWAYS_HIDDEN = -3;
static CameraMode_t CAMERA_MODE_ALWAYS_VISIBLE = -2;
static CameraMode_t CAMERA_MODE_3RDPERSON_ONLY = -1;

enum ShifterPropAnim
{
Expand Down Expand Up @@ -171,9 +172,11 @@ struct Prop
std::string pp_media[2]; //!< Redundant, for Tuning UI. Media1 = prop mesh name, Media2 = steeringwheel mesh/beaconprop flare mat.
std::vector<PropAnim> pp_animations;

// Visibility control
int pp_camera_mode_active = CAMERA_MODE_ALWAYS_VISIBLE; //!< Dynamic visibility mode {0 and higher = cinecam index}
int pp_camera_mode_orig = CAMERA_MODE_ALWAYS_VISIBLE; //!< Dynamic visibility mode {0 and higher = cinecam index}
/// @name Visibility control (same as flexbody - see file FlexBody.h)
/// @{
CameraMode_t pp_camera_mode_active = CAMERA_MODE_ALWAYS_VISIBLE; //!< Dynamic visibility mode {0 and higher = cinecam index}
CameraMode_t pp_camera_mode_orig = CAMERA_MODE_ALWAYS_VISIBLE; //!< Dynamic visibility mode {0 and higher = cinecam index}
/// @}

// Special prop - steering wheel
MeshObject* pp_wheel_mesh_obj = nullptr;
Expand Down
12 changes: 12 additions & 0 deletions source/main/gui/DashBoardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ int DashBoardManager::getLinkIDForName(Ogre::String& str)
return -1;
}

std::string DashBoardManager::getLinkNameForID(DashData id)
{
if (id > 0 && id < DD_MAX)
{
return data[id].name;
}
else
{
return "";
}
}

int DashBoardManager::loadDashBoard(Ogre::String filename, bool textureLayer)
{

Expand Down
1 change: 1 addition & 0 deletions source/main/gui/DashBoardManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class DashBoardManager
int getDataType(size_t key) { return data[key].type; };

int getLinkIDForName(Ogre::String& str);
std::string getLinkNameForID(DashData id);

int loadDashBoard(Ogre::String filename, bool textureLayer);

Expand Down
15 changes: 14 additions & 1 deletion source/main/gui/panels/GUI_FlexbodyDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ void FlexbodyDebug::DrawDebugView(FlexBody* flexbody, Prop* prop, NodeNum_t node

void FlexbodyDebug::UpdateVisibility()
{
// Both flexbodies and props use the same dynamic visibility mode, see `CameraMode_t` typedef and constants in file GfxData.h
// ---------------------------------------------------------------------------------------------------------------------------

ActorPtr actor = App::GetGameContext()->GetPlayerActor();
if (!actor)
{
Expand All @@ -442,13 +445,18 @@ void FlexbodyDebug::UpdateVisibility()
{
prop.pp_camera_mode_active = CAMERA_MODE_ALWAYS_HIDDEN;
}
// Override flexbody dynamic visibility mode
for (FlexBody* flexbody: actor->GetGfxActor()->GetFlexbodies())
{
flexbody->fb_camera_mode_active = CAMERA_MODE_ALWAYS_HIDDEN;
}

// Then re-display what we need manually.
auto& flexbody_vec = actor->GetGfxActor()->GetFlexbodies();
const int combo_flexbody_selection = m_combo_selection;
if (combo_flexbody_selection >= 0 && combo_flexbody_selection < (int)flexbody_vec.size())
{
flexbody_vec[combo_flexbody_selection]->setVisible(true);
flexbody_vec[combo_flexbody_selection]->fb_camera_mode_active = CAMERA_MODE_ALWAYS_VISIBLE;
}

auto& prop_vec = actor->GetGfxActor()->getProps();
Expand All @@ -472,6 +480,11 @@ void FlexbodyDebug::UpdateVisibility()
{
prop.pp_camera_mode_active = prop.pp_camera_mode_orig;
}
// Restore flexbody dynamic visibility mode
for (FlexBody* flexbody: actor->GetGfxActor()->GetFlexbodies())
{
flexbody->fb_camera_mode_active = flexbody->fb_camera_mode_orig;
}
}
}

Expand Down