og-odamex/common/gstrings.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
2.1 KiB
C++
Raw Permalink Normal View History

2020-05-07 19:03:27 -04:00
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id$
//
// Copyright (C) 1998-2011 by Randy Heit (ZDoom 1.22).
2026-01-05 01:52:47 +00:00
// Copyright (C) 2006-2026 by The Odamex Team.
2020-05-07 19:03:27 -04:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// GSTRINGS Define
//
//-----------------------------------------------------------------------------
#include "odamex.h"
2020-05-07 19:03:27 -04:00
#include "gstrings.h"
#include "c_dispatch.h"
// Localizable strings
StringTable GStrings;
static void StringinfoHelp()
{
2025-08-21 06:28:48 -05:00
PrintFmt(PRINT_HIGH,
2020-05-07 19:03:27 -04:00
"stringinfo - Looks up internal information about strings\n\n"
"Usage:\n"
" ] stringinfo name <STRINGNAME>\n"
" Looks up a string by name STRINGNAME.\n\n"
" ] stringinfo index <INDEX>\n"
" Looks up a string by index INDEX.\n\n"
" ] stringinfo size\n"
" Return the size of the internal stringtable.\n\n"
" ] stringinfo dump\n"
" Dumps all strings in the stringtable. Sometimes a blunt instrument is appropriate.\n");
2020-05-07 19:03:27 -04:00
}
BEGIN_COMMAND(stringinfo)
{
if (argc < 2)
{
StringinfoHelp();
return;
}
if (stricmp(argv[1], "size") == 0)
{
2025-08-21 06:28:48 -05:00
PrintFmt("{} strings found\n", GStrings.size());
2020-05-07 19:03:27 -04:00
return;
}
else if (stricmp(argv[1], "dump") == 0)
{
GStrings.dumpStrings();
return;
}
2020-05-07 19:03:27 -04:00
if (argc < 3)
{
StringinfoHelp();
return;
}
if (stricmp(argv[1], "name") == 0)
{
2025-08-21 06:28:48 -05:00
PrintFmt(PRINT_HIGH, "{} = \"{}\"\n", argv[2], GStrings(argv[2]));
2020-05-07 19:03:27 -04:00
return;
}
else if (stricmp(argv[1], "index") == 0)
{
int index = atoi(argv[2]);
2025-08-21 06:28:48 -05:00
PrintFmt(PRINT_HIGH, "{} = \"{}\"\n", argv[2], GStrings.getIndex(index));
2020-05-07 19:03:27 -04:00
return;
}
StringinfoHelp();
}
END_COMMAND(stringinfo)