Skip to content

Commit

Permalink
vscode file changes, xmodel selector fixes
Browse files Browse the repository at this point in the history
vscode:
- moved vscode files into sub-directory .vscode/tracked/ so the user has to drag them manually into .vscode/ (untrack files inside the vscode dir so I can add them to gitignore on the next commit -> will allow custom vscode settings)

xmodel selector:
- fixed a nullptr assert for bad / default xmodels
- fixed up/down arrow scrolling if textfilter is active
  • Loading branch information
xoxor4d committed Nov 23, 2021
1 parent 99d2713 commit 0937110
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ user*.bat
*.tmp
*.aps

!.vscode/tracked
!.vscode/readme.txt

# IDA
# =========================
*.id0
Expand Down
7 changes: 4 additions & 3 deletions .vscode/readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
1.) Install C++ Build tools (msbuild)
2.) Add msbuild to the "PATH" environment variable (eg. "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin")
3.) Add "COD4_ROOT" environment variable with path to your cod4 directory (eg. "COD4_ROOT" "D:\COD4-Modtools")
4.) Open "iw3xo-radiant.code-workspace"
5.) Run task "update_submodules" or open "update_submodules.bat"
6.) Run task "generate-buildfiles" or open "generate-buildfiles.bat"
4.) Drag and drop all files from ".vscode/tracked\" into ".vscode\ (we ignore all files in .vscode/ besides the readme)
5.) Open "iw3xo-radiant.code-workspace"
6.) Run task "update_submodules" or open "update_submodules.bat"
7.) Run task "generate-buildfiles" or open "generate-buildfiles.bat"

Use provided build-tasks to build debug/release builds with the option to copy iw3r.dll and iw3r.pdb to %COD4_ROOT%/bin.
Run->Start Debugging will build and copy a debug build to to %COD4_ROOT%/bin and launch IW3xRadiant.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 10 additions & 4 deletions src/common/layermatwnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,20 @@ void clayermatwnd::on_paint()
{
if (m_selector->menustate && !m_selector->preview_model_name.empty())
{
m_selector->bad_model = false;

// get model handle
if(auto model = game::R_RegisterModel(m_selector->preview_model_name.c_str());
model)
{
// use the fx model for vertex heavy models
if (model->surfs->vertCount > 15000) {
model = game::R_RegisterModel("fx");
}
// use the fx model for invalid or vertex heavy models
if( !model->surfs
|| model->bad
|| model->surfs->vertCount > 15000)
{
model = game::R_RegisterModel("fx");
m_selector->bad_model = true;
}

// begin a new frame, clear the scene
game::R_BeginFrame();
Expand Down
1 change: 1 addition & 0 deletions src/ggui/_ggui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace ggui
std::string preview_model_name;
game::XModel* preview_model_ptr;
int preview_model_inst_handle;
bool bad_model;

// raw/xmodel folder
int xmodel_filecount;
Expand Down
55 changes: 49 additions & 6 deletions src/ggui/modelselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,56 @@ namespace ggui::modelselector
{
if(m_selector->xmodel_selection + 1 < m_selector->xmodel_filecount)
{
m_selector->xmodel_selection += 1;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];
if (m_filter.IsActive())
{
for (int i = m_selector->xmodel_selection + 1; i < m_selector->xmodel_filecount; i++)
{
if (!m_filter.PassFilter(m_selector->xmodel_filelist[i])) {
continue;
}

update_scroll_pos = true;
m_selector->xmodel_selection = i;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];

update_scroll_pos = true;
break;
}
}
else
{
m_selector->xmodel_selection += 1;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];

update_scroll_pos = true;
}
}
}
else if(ImGui::IsKeyPressedMap(ImGuiKey_UpArrow))
{
if (m_selector->xmodel_selection - 1 >= 0)
{
m_selector->xmodel_selection -= 1;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];
if (m_filter.IsActive())
{
for (int i = m_selector->xmodel_selection - 1; i >= 0; i--)
{
if (!m_filter.PassFilter(m_selector->xmodel_filelist[i])) {
continue;
}

update_scroll_pos = true;
m_selector->xmodel_selection = i;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];

update_scroll_pos = true;
break;
}
}
else
{
m_selector->xmodel_selection -= 1;
m_selector->preview_model_name = m_selector->xmodel_filelist[m_selector->xmodel_selection];

update_scroll_pos = true;
}
}
}

Expand Down Expand Up @@ -226,6 +262,13 @@ namespace ggui::modelselector
"Mouse Scroll:\t\t\t Zoom\n"
"Up/Down Arrow:\t\tChange selection\n"
"- Drag and drop xmodel from list to grid or camera to spawn it");

if(m_selector->bad_model)
{
ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 1.0f);
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Bad model");
}
}

ImGui::EndChild();
Expand Down

0 comments on commit 0937110

Please sign in to comment.