Skip to content

Commit

Permalink
Sprays - Initial commit
Browse files Browse the repository at this point in the history
* Integrate stb_image.h library
* rought draft
* fixes NeotokyoRebuild#602
  • Loading branch information
nullsystem committed Oct 8, 2024
1 parent bc8e217 commit f04a268
Show file tree
Hide file tree
Showing 9 changed files with 8,329 additions and 2 deletions.
9 changes: 9 additions & 0 deletions mp/src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target_include_directories(client
${CMAKE_SOURCE_DIR}/game/shared/neo/weapons
${CMAKE_SOURCE_DIR}/public
${CMAKE_SOURCE_DIR}/thirdparty/sixensesdk/include
${CMAKE_SOURCE_DIR}/vendor
game_controls
hl2
hl2/elements
Expand Down Expand Up @@ -1486,6 +1487,14 @@ target_sources_grouped(
neo/neo_fixup_glshaders.h
)

target_sources_grouped(
TARGET client
NAME "Source Files\\NEO_Vendor"
FILES
neo/vendor_impl.cpp
${CMAKE_SOURCE_DIR}/vendor/stb_image.h
)

target_sources_grouped(
TARGET client
NAME "Source Files\\NEO\\Game_Controls"
Expand Down
52 changes: 50 additions & 2 deletions mp/src/game/client/neo/ui/neo_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,8 +1502,56 @@ void CNeoRoot::ReadNewsFile(CUtlBuffer &buf)

void CNeoRoot::OnFileSelected(const char *szFullpath)
{
((m_ns.crosshair.eFileIOMode == vgui::FOD_OPEN) ?
&ImportCrosshair : &ExportCrosshair)(&m_ns.crosshair.info, szFullpath);
switch (m_eFileIOMode)
{
case FILEIODLGMODE_CROSSHAIR:
((m_ns.crosshair.eFileIOMode == vgui::FOD_OPEN) ?
&ImportCrosshair : &ExportCrosshair)(&m_ns.crosshair.info, szFullpath);
break;
case FILEIODLGMODE_SPRAY:
{
char szRetTexPath[VTF_PATH_MAX] = {};
uint8 *data = NeoUI::ConvertToVTF(&szRetTexPath, szFullpath);

char szRetVtfPath[PATH_MAX];
V_sprintf_safe(szRetVtfPath, "%s.vtf", szRetTexPath);

ConVarRef("cl_logofile").SetValue(szRetVtfPath);
if (m_ns.general.iTexIdSpray > 0)
{
vgui::surface()->DeleteTextureByID(m_ns.general.iTexIdSpray);
}
#if 1
m_ns.general.iTexIdSpray = vgui::surface()->CreateNewTextureID(true);
//vgui::surface()->DrawSetTextureFile(m_ns.general.iTexIdSpray, szRetTexPath, false, false);
vgui::surface()->DrawSetTextureRGBA(m_ns.general.iTexIdSpray, data, 256, 256, false, false);
free(data);
#else
CUtlBuffer buf(0, 0, CUtlBuffer::READ_ONLY);
if (filesystem->ReadFile(szRetFullPath, nullptr, buf))
{
IVTFTexture *pVTFTexture = CreateVTFTexture();
if (pVTFTexture->Unserialize(buf))
{
const auto width = pVTFTexture->Width();
const auto height = pVTFTexture->Height();
const auto depth = pVTFTexture->Depth();
const auto format = pVTFTexture->Format();
const auto flags = pVTFTexture->Flags();
const auto mip = pVTFTexture->MipCount();
const auto face = pVTFTexture->FaceCount();
const auto frame = pVTFTexture->FrameCount();
}
//DestroyVTFTexture(pVTFTexture);
//stbi_image_free(data);
}
#endif
break;
}
default:
break;
}
}

// NEO NOTE (nullsystem): NeoRootCaptureESC is so that ESC keybinds can be recognized by non-root states, but root
Expand Down
8 changes: 8 additions & 0 deletions mp/src/game/client/neo/ui/neo_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ class CNeoRoot : public vgui::EditablePanel, public CGameEventListener
void ReadNewsFile(CUtlBuffer &buf);
bool m_bShowBrowserLabel = false;

enum FileIODialogMode
{
FILEIODLGMODE_CROSSHAIR = 0,
FILEIODLGMODE_SPRAY,

FILEIODLGMODE__TOTAL,
};
FileIODialogMode m_eFileIOMode;
vgui::FileOpenDialog *m_pFileIODialog = nullptr;
MESSAGE_FUNC_CHARPTR(OnFileSelected, "FileSelected", fullpath);
};
Expand Down
40 changes: 40 additions & 0 deletions mp/src/game/client/neo/ui/neo_root_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey
}
}
}

if (pGeneral->iTexIdSpray > 0)
{
vgui::surface()->DeleteTextureByID(pGeneral->iTexIdSpray);
}
const char *szLogo = ConVarRef("cl_logofile").GetString();
if (szLogo)
{
pGeneral->iTexIdSpray = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile(pGeneral->iTexIdSpray, szLogo, false, false);
}
}
{
NeoSettings::Keys *pKeys = &ns->keys;
Expand Down Expand Up @@ -628,6 +639,34 @@ void NeoSettings_General(NeoSettings *ns)
NeoUI::RingBoxBool(L"Show position", &pGeneral->bShowPos);
NeoUI::RingBox(L"Show FPS", SHOWFPS_LABELS, ARRAYSIZE(SHOWFPS_LABELS), &pGeneral->iShowFps);
NeoUI::RingBox(L"Download filter", DLFILTER_LABELS, ARRAYSIZE(DLFILTER_LABELS), &pGeneral->iDlFilter);

NeoUI::Pad();
if (NeoUI::Button(L"", L"Import spray").bPressed)
{
if (g_pNeoRoot->m_pFileIODialog)
{
g_pNeoRoot->m_pFileIODialog->MarkForDeletion();
}
g_pNeoRoot->m_pFileIODialog = new vgui::FileOpenDialog(g_pNeoRoot, "Import spray", vgui::FOD_OPEN);
g_pNeoRoot->m_eFileIOMode = CNeoRoot::FILEIODLGMODE_SPRAY;
g_pNeoRoot->m_pFileIODialog->AddFilter("*.jpg;*.jpeg;*.png;*.vtf", "Images (JPEG, PNG, VTF)", true);
g_pNeoRoot->m_pFileIODialog->AddFilter("*.jpg;*.jpeg", "JPEG Image", false);
g_pNeoRoot->m_pFileIODialog->AddFilter("*.png", "PNG Image", false);
g_pNeoRoot->m_pFileIODialog->AddFilter("*.vtf", "VTF Image", false);
g_pNeoRoot->m_pFileIODialog->DoModal();
}
NeoUI::Pad();

if (pGeneral->iTexIdSpray > 0)
{
vgui::surface()->DrawSetTexture(pGeneral->iTexIdSpray);
vgui::surface()->DrawSetColor(COLOR_WHITE);
vgui::surface()->DrawTexturedRect(
g_uiCtx.dPanel.x + g_uiCtx.iLayoutX,
g_uiCtx.dPanel.y + g_uiCtx.iLayoutY,
g_uiCtx.dPanel.x + g_uiCtx.iLayoutX + 256,
g_uiCtx.dPanel.y + g_uiCtx.iLayoutY + 256);
}
}

void NeoSettings_Keys(NeoSettings *ns)
Expand Down Expand Up @@ -786,6 +825,7 @@ void NeoSettings_Crosshair(NeoSettings *ns)
g_pNeoRoot->m_pFileIODialog->MarkForDeletion();
}
pCrosshair->eFileIOMode = bPresImport ? vgui::FOD_OPEN : vgui::FOD_SAVE;
g_pNeoRoot->m_eFileIOMode = CNeoRoot::FILEIODLGMODE_CROSSHAIR;
g_pNeoRoot->m_pFileIODialog = new vgui::FileOpenDialog(g_pNeoRoot,
bPresImport ? "Import crosshair" : "Export crosshair",
pCrosshair->eFileIOMode);
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/client/neo/ui/neo_root_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct NeoSettings
bool bShowPos;
int iShowFps;
int iDlFilter;

int iTexIdSpray;
};

struct Keys
Expand Down
Loading

0 comments on commit f04a268

Please sign in to comment.