Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/coelckers/gzdoom
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 11, 2022
2 parents 50d16c7 + 8e50c59 commit 283c5d6
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/common/console/c_enginecmds.cpp
Expand Up @@ -52,6 +52,10 @@
#include "version.h"
#include "findfile.h"
#include "md5.h"
#include "i_specialpaths.h"

void I_OpenShellFolder(const char*);
void I_OpenShellFile(const char*);

extern FILE* Logfile;

Expand Down Expand Up @@ -336,3 +340,19 @@ CCMD(printlocalized)
}

}

CCMD(opensaves)
{
I_OpenShellFolder(M_GetSavegamesPath().GetChars());
}

CCMD(openscreenshots)
{
I_OpenShellFolder(M_GetScreenshotsPath().GetChars());
}

CCMD(openconfig)
{
I_OpenShellFile(M_GetConfigPath(false).GetChars());
}

15 changes: 15 additions & 0 deletions src/common/platform/posix/cocoa/i_system.mm
Expand Up @@ -170,3 +170,18 @@ unsigned int I_MakeRNGSeed()
{
return static_cast<unsigned int>(arc4random());
}

void I_OpenShellFolder(const char* folder)
{
std::string x = (std::string)"open " + (std::string)folder;
Printf("Opening folder: %s\n", folder);
std::system(x.c_str());
}

void I_OpenShellFile(const char* file)
{
std::string x = (std::string)"open " + (std::string)file;
x.erase(x.find_last_of('/'), std::string::npos);
Printf("Opening folder to file: %s\n", file);
std::system(x.c_str());
}
16 changes: 16 additions & 0 deletions src/common/platform/posix/sdl/i_system.cpp
Expand Up @@ -431,3 +431,19 @@ unsigned int I_MakeRNGSeed()
}
return seed;
}

void I_OpenShellFolder(const char* folder)
{
std::string x = (std::string)"xdg-open " + (std::string)folder;
Printf("Opening folder: %s\n", folder);
std::system(x.c_str());
}

void I_OpenShellFile(const char* file)
{
std::string x = (std::string)"xdg-open " + (std::string)file;
x.erase(x.find_last_of('/'), std::string::npos);
Printf("Opening folder to file: %s\n", file);
std::system(x.c_str());
}

2 changes: 1 addition & 1 deletion src/common/platform/win32/i_specialpaths.cpp
Expand Up @@ -283,7 +283,7 @@ FString M_GetScreenshotsPath()

if (!UseKnownFolders())
{
path << progdir << "/Screenshots/";
path << progdir << "Screenshots/";
}
else if (GetKnownFolder(-1, MyFOLDERID_Screenshots, true, path))
{
Expand Down
22 changes: 22 additions & 0 deletions src/common/platform/win32/i_system.cpp
Expand Up @@ -6,6 +6,7 @@
** Copyright 1998-2009 Randy Heit
** Copyright (C) 2007-2012 Skulltag Development Team
** Copyright (C) 2007-2016 Zandronum Development Team
** Copyright (C) 2017-2022 GZDoom Development Team
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -49,6 +50,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdexcept>
#include <process.h>
#include <time.h>
#include <map>
Expand All @@ -62,6 +64,8 @@
#include <wincrypt.h>
#include <shlwapi.h>

#include <shellapi.h>

#include "hardware.h"
#include "printf.h"

Expand Down Expand Up @@ -955,3 +959,21 @@ void I_SetThreadNumaNode(std::thread &thread, int numaNode)
SetThreadAffinityMask(handle, (DWORD_PTR)numaNodes[numaNode].affinityMask);
}
}

void I_OpenShellFolder(const char* folder)
{
FString proc = folder;
proc.ReplaceChars('/', '\\');
Printf("Opening folder: %s\n", proc.GetChars());
ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL);
}

void I_OpenShellFile(const char* file)
{
FString proc = file;
proc.ReplaceChars('/', '\\');
Printf("Opening folder to file: %s\n", proc.GetChars());
proc.Format("/select,%s", proc.GetChars());
ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL);
}

2 changes: 1 addition & 1 deletion src/console/c_cmds.cpp
Expand Up @@ -73,7 +73,7 @@
extern FILE *Logfile;
extern bool insave;

CVAR (Bool, sv_cheats, false, CVAR_SERVERINFO | CVAR_LATCH)
CVAR (Bool, sv_cheats, false, CVAR_SERVERINFO)
CVAR (Bool, sv_unlimited_pickup, false, CVAR_SERVERINFO)
CVAR (Int, cl_blockcheats, 0, 0)

Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/menudef.txt
Expand Up @@ -380,6 +380,9 @@ OptionMenu "OptionsMenu" protected
SafeCommand "$OPTMNU_WRITEINI", "writeini"

Command "$OPTMNU_CONSOLE", "menuconsole"
Command "$OPTMNU_OPENCONFIG", "openconfig"
Command "$OPTMNU_OPENSCREENSHOTS", "openscreenshots"
Command "$OPTMNU_OPENSAVES", "opensaves"
StaticText " "
}

Expand Down

0 comments on commit 283c5d6

Please sign in to comment.