Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed May 28, 2023
2 parents 01f3e14 + 484630d commit a9c38d6
Show file tree
Hide file tree
Showing 32 changed files with 1,108 additions and 336 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ the dated MFC/Windows UI with a more modern and flexible UI powered by Dear ImGu
<br>

### Project Page (Guide / In-Depth)
https://xoxor4d.github.io/projects/iw3xo-radiant
xoxor4d.github.io/projects/iw3xo-radiant

#### Changelog
github.com/xoxor4d/iw3xo-radiant/wiki/Changelog

<br>

Expand Down
2 changes: 1 addition & 1 deletion assets/bin/IW3xRadiant/hotkeys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ExtrudeTerrainRow = +alt O
RemoveTerrainRow = +shift +ctrl Q
SplitPatch = +shift +ctrl X
SurfaceInspector = S
PatchInspector = +shift S
PatchInspector =
ApplyPatchCap = +shift +ctrl P
TolerantWeld = +shift +ctrl J
RedisperseVertices = +shift F
Expand Down
Binary file added assets/bin/IW3xRadiant/images/layers.iwi
Binary file not shown.
13 changes: 12 additions & 1 deletion assets/bin/iw3xradiant.def
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,18 @@ NO_STATIC_SHADOWS - the opaque surfaces will not cast static light map shadows
*/

/*QUAKED fx_origin (0.45 0.3 0.2) (-2 -2 -2) (2 2 2)
default:"fx" "iw3xradiant_def"
used for createFX generation and general effect handling.
default: "fx" "iw3xradiant_def"
default: "loopfx" "0"
default: "loop_wait" "5"
default: "is_sound" "0"
default: "soundalias" "none"

fx - effect definition
fxloop - make createFX gen. use loopfx instead of createOneshotEffect
loop_wait - time to wait until re-triggering (fxloop)
is_sound - make createFX gen. use createLoopSound, ignores fx settings if enabled (0/1)
soundalias - soundalias to use for createLoopSound
*/


Expand Down
2 changes: 1 addition & 1 deletion src/common/cxywnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void __declspec(naked) draw_grid_block_text_stub()
// fix entity name drawing
void draw_entity_names_hk(const char* text, game::Font_s* font, float* origin, float* pixel_step_x, float* pixel_step_y, [[maybe_unused]] float* color)
{
components::renderer::R_AddCmdDrawTextAtPosition(text, font, origin, pixel_step_x, pixel_step_y, game::g_qeglobals->d_savedinfo.colors[game::COLOR_ENTITYUNK]);
components::renderer::R_AddCmdDrawTextAtPosition(text, font, origin, pixel_step_x, pixel_step_y, game::g_qeglobals->d_savedinfo.colors[game::COLOR_VIEWNAME]); // game::COLOR_ENTITYUNK (changes when using the colordialog tool)
}

bool g_block_radiant_modeldialog = false;
Expand Down
3 changes: 2 additions & 1 deletion src/common/imgui/imgui_notify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ enum ImGuiToastPos_
class ImGuiToast
{
private:
ImGuiToastType type = ImGuiToastType_None;
char title[NOTIFY_MAX_MSG_LENGTH];
char content[NOTIFY_MAX_MSG_LENGTH];
int dismiss_time = NOTIFY_DEFAULT_DISMISS;
public:
ImGuiToastType type = ImGuiToastType_None;
uint64_t creation_time = 0;

private:
Expand Down
125 changes: 102 additions & 23 deletions src/components/modules/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,16 @@ namespace components
// map of fx defs present on the map (used so we do not load the same def multiple times)
std::unordered_map<std::string, std::string> createfx_loaded_fx_defs;

// list of loopfx (fx_origins marked as looping), contains <def name> <x, y, z, timeout>
//std::unordered_map<std::string, std::string> createfx_looping_fx_defs;
struct loopfx_def_s
{
std::string def_num;
std::string pos_and_timeout;
};

std::vector<loopfx_def_s> createfx_looping_fx_defs;

// world orientations per prefab level
std::vector<game::orientation_t> createfx_prefab_stack_orientations;

Expand Down Expand Up @@ -649,29 +659,49 @@ namespace components
effect_num = itr->second;
}

createfx << "\tent = maps\\mp\\_utility::createOneshotEffect( \"effect_" << effect_num << "\" );" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << out_orient.origin[0] << ", " << out_orient.origin[1] << ", " << out_orient.origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << out_angles[0] << ", " << out_angles[1] << ", " << out_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"fxid\" ] = \"effect_" << effect_num << "\";" << std::endl;
createfx << "\tent.v[ \"delay\" ] = -15;" << std::endl << std::endl;





// is sound
if (entity_gui->has_key_with_value(owner, "is_sound", "1"))
{
std::string soundalias_name = "UNSET";

if (const char* soundalias_str = entity_gui->get_value_for_key_from_epairs(owner->epairs, "soundalias"); soundalias_str)
{
soundalias_name = soundalias_str;
}

createfx << "\tent = maps\\mp\\_createfx::createLoopSound();" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << out_orient.origin[0] << ", " << out_orient.origin[1] << ", " << out_orient.origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << out_angles[0] << ", " << out_angles[1] << ", " << out_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"soundalias\" ] = \"" << soundalias_name.c_str() << "\";" << std::endl << std::endl;
}

// is fx
else
{
std::string loopfx_timeout = "100";

/*def << "\tlevel._effect[ \"effect_" << *effect_count << "\" ] = loadfx( \"" << fx_path << "\" );" << std::endl;
if (const char* timeout_str = entity_gui->get_value_for_key_from_epairs(owner->epairs, "loop_wait"); timeout_str)
{
loopfx_timeout = timeout_str;
}

createfx << "\tent = maps\\mp\\_utility::createOneshotEffect( \"effect_" << *effect_count << "\" );" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << out_orient.origin[0] << ", " << out_orient.origin[1] << ", " << out_orient.origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << out_angles[0] << ", " << out_angles[1] << ", " << out_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"fxid\" ] = \"effect_" << *effect_count << "\";" << std::endl;
createfx << "\tent.v[ \"delay\" ] = -15;" << std::endl << std::endl;
// is looping (make oneshot looping by re-triggering them)
if (entity_gui->has_key_with_value(owner, "loopfx", "1"))
{
createfx_looping_fx_defs.emplace_back(effect_num,
utils::va("%.2f, %.2f, %.2f, %s", out_orient.origin[0], out_orient.origin[1], out_orient.origin[2], loopfx_timeout.c_str()));
}

*effect_count += 1;*/
// is oneshot (either real oneshot or indefinitely looping)
else
{
createfx << "\tent = maps\\mp\\_utility::createOneshotEffect( \"effect_" << effect_num << "\" );" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << out_orient.origin[0] << ", " << out_orient.origin[1] << ", " << out_orient.origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << out_angles[0] << ", " << out_angles[1] << ", " << out_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"fxid\" ] = \"effect_" << effect_num << "\";" << std::endl;
createfx << "\tent.v[ \"delay\" ] = -15;" << std::endl << std::endl;
}
}
}
else if (prefab && prefab->owner && prefab->owner->prefab && prefab->owner->firstActive && prefab->owner->firstActive->eclass && prefab->owner->firstActive->eclass->classtype & game::ECLASS_PREFAB)
{
Expand Down Expand Up @@ -700,6 +730,7 @@ namespace components
{
// reset global vars
createfx_loaded_fx_defs.clear();
createfx_looping_fx_defs.clear();
createfx_prefab_stack_level = 0;
createfx_prefab_stack_orientations.clear();
createfx_prefab_stack_orientations.reserve(8);
Expand Down Expand Up @@ -798,13 +829,50 @@ namespace components
effect_num = itr->second;
}

createfx << "\tent = maps\\mp\\_utility::createOneshotEffect( \"effect_" << effect_num << "\" );" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << owner->origin[0] << ", " << owner->origin[1] << ", " << owner->origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << world_angles[0] << ", " << world_angles[1] << ", " << world_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"fxid\" ] = \"effect_" << effect_num << "\";" << std::endl;
createfx << "\tent.v[ \"delay\" ] = -15;" << std::endl << std::endl;


// is sound
if (entity_gui->has_key_with_value(owner, "is_sound", "1"))
{
std::string soundalias_name = "UNSET";

if (const char* soundalias_str = entity_gui->get_value_for_key_from_epairs(owner->epairs, "soundalias"); soundalias_str)
{
soundalias_name = soundalias_str;
}

createfx << "\tent = maps\\mp\\_createfx::createLoopSound();" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << owner->origin[0] << ", " << owner->origin[1] << ", " << owner->origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << world_angles[0] << ", " << world_angles[1] << ", " << world_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"soundalias\" ] = \"" << soundalias_name.c_str() << "\";" << std::endl << std::endl;
}

// is fx
else
{
std::string loopfx_timeout = "100";

if (const char* timeout_str = entity_gui->get_value_for_key_from_epairs(owner->epairs, "loop_wait"); timeout_str)
{
loopfx_timeout = timeout_str;
}

// is looping (make oneshot looping by re-triggering them)
if (entity_gui->has_key_with_value(owner, "loopfx", "1"))
{
createfx_looping_fx_defs.emplace_back(effect_num,
utils::va("%.2f, %.2f, %.2f, %s", owner->origin[0], owner->origin[1], owner->origin[2], loopfx_timeout.c_str()));
}

// is oneshot (either real oneshot or indefinitely looping)
else
{
createfx << "\tent = maps\\mp\\_utility::createOneshotEffect( \"effect_" << effect_num << "\" );" << std::endl;
createfx << "\tent.v[ \"origin\" ] = ( " << std::fixed << std::setprecision(2) << owner->origin[0] << ", " << owner->origin[1] << ", " << owner->origin[2] << " );" << std::endl;
createfx << "\tent.v[ \"angles\" ] = ( " << std::fixed << std::setprecision(2) << world_angles[0] << ", " << world_angles[1] << ", " << world_angles[2] << " );" << std::endl;
createfx << "\tent.v[ \"fxid\" ] = \"effect_" << effect_num << "\";" << std::endl;
createfx << "\tent.v[ \"delay\" ] = -15;" << std::endl << std::endl;
}
}
}

if (sb == game::g_active_brushes())
Expand All @@ -818,6 +886,17 @@ namespace components
}
}

if (!createfx_looping_fx_defs.empty())
{
def << std::endl;

for (const auto& loop : createfx_looping_fx_defs)
{
const auto split = utils::split(loop.pos_and_timeout, ',');
def << "\tmaps\\mp\\_fx::loopfx(\"effect_" << loop.def_num << "\", (" << split[0] << ", " << split[1] << ", " << split[2] << "), " << split[3] << ");" << std::endl;
}
}

def << "}" << std::endl;
createfx << "}" << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ namespace components
/* name */ "gui_saved_state_toolbox_child",
/* default */ 0,
/* mins */ 0,
/* maxs */ 4,
/* maxs */ 5,
/* flags */ game::dvar_flags::saved,
/* desc */ "saved closed/opened/active state of window");
}
Expand Down
19 changes: 16 additions & 3 deletions src/components/modules/main_module.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "std_include.hpp"
#include <WinHttpClient.h>
#include <codecvt>

bool get_html(const std::string& url, std::wstring& header, std::wstring& hmtl)
{
Expand Down Expand Up @@ -43,15 +44,27 @@ DWORD WINAPI update_check(LPVOID)
std::wstring header, html;
get_html(url, header, html);

std::ranges::transform(html.begin(), html.end(), std::back_inserter(game::glob::gh_update_releases_json), [](wchar_t c)
/*std::ranges::transform(html.begin(), html.end(), std::back_inserter(game::glob::gh_update_releases_json), [](wchar_t c)
{
return (char)c;
});
});*/

// chatgpt is awesome
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
game::glob::gh_update_releases_json = converter.to_bytes(html);

if (!game::glob::gh_update_releases_json.empty())
{
rapidjson::Document doc;
doc.Parse(game::glob::gh_update_releases_json.c_str());

if (doc.Parse(game::glob::gh_update_releases_json.c_str()).HasParseError())
{
#if DEBUG
auto err = doc.GetParseError();
__debugbreak();
#endif
return TRUE;
}

if (!doc.Empty())
{
Expand Down
3 changes: 1 addition & 2 deletions src/components/modules/physx_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,7 @@ namespace components
p->setAngularVelocity(null_vec);

// check

if (user_data->entity->firstActive->firstBrush->owner && user_data->entity->firstActive->firstBrush->owner->eclass)
if (user_data->entity->firstActive->brushes.oprev->owner && user_data->entity->firstActive->brushes.oprev->owner->eclass)
{
// reset prefab entity

Expand Down
Loading

0 comments on commit a9c38d6

Please sign in to comment.