Skip to content

Commit cbd0e7f

Browse files
committed
Merge branch 'dev'
2 parents 3181886 + 766af8d commit cbd0e7f

File tree

101 files changed

+849
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+849
-107
lines changed

native/src/ReachVariantTool/ReachVariantTool.vcxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<BuildStlModules>false</BuildStlModules>
7575
</ClCompile>
7676
<Link>
77-
<SubSystem>Windows</SubSystem>
77+
<SubSystem>Console</SubSystem>
7878
<GenerateDebugInformation>true</GenerateDebugInformation>
7979
</Link>
8080
<QtUic>
@@ -94,14 +94,15 @@
9494
<EnableModules>false</EnableModules>
9595
</ClCompile>
9696
<Link>
97-
<SubSystem>Windows</SubSystem>
97+
<SubSystem>Console</SubSystem>
9898
<GenerateDebugInformation>false</GenerateDebugInformation>
9999
</Link>
100100
<QtUic>
101101
<QtUicDir>$(IntDir)uic\%(RelativeDir)</QtUicDir>
102102
</QtUic>
103103
</ItemDefinitionGroup>
104104
<ItemGroup>
105+
<ClCompile Include="cli.cpp" />
105106
<ClCompile Include="editor_state\ReachStringCentralModel.cpp" />
106107
<ClCompile Include="formats\block.cpp" />
107108
<ClCompile Include="formats\content_author.cpp" />
@@ -174,6 +175,7 @@
174175
<ClCompile Include="game_variants\io_process.cpp" />
175176
<ClCompile Include="game_variants\types\firefight.cpp" />
176177
<ClCompile Include="game_variants\types\multiplayer.cpp" />
178+
<ClCompile Include="headless.cpp" />
177179
<ClCompile Include="helpers\bitwriter.cpp" />
178180
<ClCompile Include="helpers\bytewriter.cpp" />
179181
<ClCompile Include="helpers\endianness.cpp" />
@@ -308,6 +310,7 @@
308310
</ItemGroup>
309311
<ItemGroup>
310312
<QtMoc Include="editor_state\ReachStringCentralModel.h" />
313+
<ClInclude Include="cli.h" />
311314
<ClInclude Include="formats\indexed_lists.h" />
312315
<ClInclude Include="formats\ugc_header.h" />
313316
<ClInclude Include="game_variants\components\custom_game_options.h" />
@@ -352,6 +355,7 @@
352355
<ClInclude Include="game_variants\io_process.h" />
353356
<ClInclude Include="game_variants\types\firefight.h" />
354357
<ClInclude Include="game_variants\warnings.h" />
358+
<ClInclude Include="headless.h" />
355359
<ClInclude Include="helpers\bitarray.h" />
356360
<ClInclude Include="helpers\ini\change_callback.h" />
357361
<ClInclude Include="helpers\ini\file.h" />

native/src/ReachVariantTool/ReachVariantTool.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@
481481
<ClCompile Include="helpers\ini\setting.cpp">
482482
<Filter>Source Files</Filter>
483483
</ClCompile>
484+
<ClCompile Include="cli.cpp">
485+
<Filter>Source Files</Filter>
486+
</ClCompile>
487+
<ClCompile Include="headless.cpp">
488+
<Filter>Source Files</Filter>
489+
</ClCompile>
484490
</ItemGroup>
485491
<ItemGroup>
486492
<QtMoc Include="ui\generic\PlayerTraitWidgets.h">
@@ -1197,6 +1203,12 @@
11971203
<ClInclude Include="helpers\ini\setting.h">
11981204
<Filter>Header Files</Filter>
11991205
</ClInclude>
1206+
<ClInclude Include="cli.h">
1207+
<Filter>Header Files</Filter>
1208+
</ClInclude>
1209+
<ClInclude Include="headless.h">
1210+
<Filter>Header Files</Filter>
1211+
</ClInclude>
12001212
</ItemGroup>
12011213
<ItemGroup>
12021214
<Image Include="ReachVariantTool.ico" />

native/src/ReachVariantTool/ReachVariantTool.vcxproj.user

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
</PropertyGroup>
66
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
77
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
8+
<LocalDebuggerCommandArguments>
9+
</LocalDebuggerCommandArguments>
10+
</PropertyGroup>
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
12+
<LocalDebuggerCommandArguments>
13+
</LocalDebuggerCommandArguments>
14+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
815
</PropertyGroup>
916
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
1017
<QtLastBackgroundBuild>2024-01-03T15:54:34.4610720Z</QtLastBackgroundBuild>
18+
<QtTouchProperty>
19+
</QtTouchProperty>
1120
</PropertyGroup>
1221
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
1322
<QtLastBackgroundBuild>2024-01-03T15:54:34.5920734Z</QtLastBackgroundBuild>
23+
<QtTouchProperty>
24+
</QtTouchProperty>
1425
</PropertyGroup>
1526
</Project>

native/src/ReachVariantTool/cli.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "./cli.h"
2+
#include <cstdio>
3+
#include <print>
4+
#include <string_view>
5+
#include "./rvt_version_macros.h"
6+
7+
namespace rvt {
8+
command_line_params::command_line_params(int argc, char* argv[]) {
9+
if (argc <= 1)
10+
return;
11+
12+
std::string_view operation = argv[1];
13+
if (operation == "--help" || operation == "/?") {
14+
this->help = true;
15+
return;
16+
}
17+
18+
if (operation == "--headless") {
19+
this->headless = true;
20+
21+
//
22+
// Currently supported commands:
23+
//
24+
// <rvt-exe> --headless <in-variant> --recompile <in-source>
25+
// <rvt-exe> --headless <in-variant> --recompile <in-source> --dst <out-variant>
26+
//
27+
28+
if (argc < 3) {
29+
this->has_error = true;
30+
std::println(stderr, "To run RVT headlessly, you must specify a game variant file to modify.");
31+
return;
32+
}
33+
this->game_variant.input = argv[2];
34+
35+
for (int i = 3; i < argc; ++i) {
36+
std::string_view arg = argv[i];
37+
bool has_next = i + 1 < argc;
38+
if (arg == "--recompile") {
39+
this->operation = headless_operation::recompile;
40+
if (!has_next) {
41+
this->has_error = true;
42+
std::println(stderr, "Expected a file path (to a file with Megalo code) after `--recompile`.");
43+
return;
44+
}
45+
this->megalo_source = argv[i + 1];
46+
++i;
47+
continue;
48+
}
49+
if (arg == "--dst") {
50+
if (!has_next) {
51+
this->has_error = true;
52+
std::println(stderr, "Expected a file path (to save the modified game variant to) after `--dst`.");
53+
return;
54+
}
55+
this->game_variant.output = argv[i + 1];
56+
++i;
57+
continue;
58+
}
59+
this->has_error = true;
60+
std::println(stderr, "Unrecognized command line parameter; stopping. Parameter was: `{}`", arg);
61+
return;
62+
}
63+
}
64+
}
65+
66+
extern void print_cli_help() {
67+
std::println("ReachVariantTool {}.{}.{}.{}", VER_MAJOR, VER_MINOR, VER_PATCH, VER_BUILD);
68+
std::println("Available commands:");
69+
std::println("--headless <in-variant> --recompile <in-source>");
70+
std::println(
71+
" Loads the game variant at the <in-variant> file path. Loads the Megalo \n"
72+
" script source code at the <in-source> file path. Attempts to recompile \n"
73+
" the game variant's script; if successful, overwrites the game variant.\n"
74+
"\n"
75+
);
76+
std::println("--headless <in-variant> --recompile <in-source> --dst <out-variant>");
77+
std::println(
78+
" Same as above, but the recompiled game variant is saved to <out-variant> \n"
79+
" (if and only if recompilation succeeds).\n"
80+
"\n"
81+
);
82+
}
83+
}

native/src/ReachVariantTool/cli.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
#include <filesystem>
3+
4+
namespace rvt {
5+
enum class headless_operation {
6+
none,
7+
recompile,
8+
};
9+
10+
struct command_line_params {
11+
command_line_params() {}
12+
command_line_params(int argc, char* argv[]);
13+
14+
headless_operation operation = headless_operation::none;
15+
bool has_error = false;
16+
bool headless = false;
17+
bool help = false;
18+
struct {
19+
std::filesystem::path input;
20+
std::filesystem::path output; // if not specified, same as input
21+
} game_variant;
22+
std::filesystem::path megalo_source;
23+
};
24+
25+
extern void print_cli_help();
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
<article>
3+
<title>Command line interface</title>
4+
<body>
5+
<p>
6+
ReachVariantTool can be run from the command line, with commands like these:
7+
</p>
8+
<pre>
9+
ReachVariantTool /?
10+
ReachVariantTool --help
11+
ReachVariantTool --headless path/to/variant --recompile path/to/megalo
12+
ReachVariantTool --headless path/to/variant --recompile path/to/megalo --dst path/to/output
13+
</pre>
14+
<hr />
15+
<p>
16+
The <code>--help</code> or <code>/?</code> command displays a list of available commands.
17+
</p>
18+
<p>
19+
The <code>--headless</code> runs RVT without its GUI, loading a game variant as input. The
20+
<code>--recompile</code> operation allows you to load script source code from a file, try
21+
to compile it into the target variant, and then re-save it. If you specify <code>--dst</code>,
22+
then the recompiled variant will be saved to that destination (if compilation succeeds);
23+
otherwise, the original file is replaced.
24+
</p>
25+
</body>
26+
</article>

native/src/ReachVariantTool/docs/working - help docs/script/api/object.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,9 @@
13741374
</arg>
13751375
<arg name="type" type="object-type" />
13761376
<arg name="radius" type="number">
1377-
Unknown. A value of 10 is equal to 1 Forge unit. Testing has not revealed any
1378-
obvious effect. A value of 0 seems safe.
1377+
The created object will have a cylinder shape, and this controls the radius.
1378+
A value of 10 represents one Forge unit. If the radius is zero or negative,
1379+
then the game will use 10 instead. Radii are clamped to the range [0, 200].
13791380
</arg>
13801381
</args>
13811382
<blurb>Spawn a new object between this object and another.</blurb>
@@ -1385,7 +1386,10 @@
13851386
<note>
13861387
Unlike <a href="script/api/object/actions/place_at_me">object.place_at_me</a>,
13871388
this function appears to spawn objects exactly in place, provided they aren't
1388-
solid or obstructed.
1389+
solid or obstructed. It also automatically gives the object a
1390+
<a href="script/api/object/actions/set_shape">shape</a> &mdash; specifically, a
1391+
cylinder, whose top and bottom lengths are set to reach from one basis object to
1392+
the other basis object.
13891393
</note>
13901394
<note>
13911395
If the same object is used as both basis objects &mdash; that is, if the object

native/src/ReachVariantTool/editor_state.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ namespace {
2727
}
2828

2929
ReachEditorState::ReachEditorState() {
30+
31+
bool is_headless = qobject_cast<QGuiApplication*>(QApplication::instance()) == nullptr;
32+
3033
QObject::connect(this, &ReachEditorState::stringModified, [this](uint32_t index) {
3134
auto mp = this->multiplayerData();
3235
if (!mp)
@@ -60,7 +63,7 @@ ReachEditorState::ReachEditorState() {
6063
}
6164
}
6265
}
63-
{
66+
if (!is_headless) {
6467
std::wstring dir;
6568
if (cobb::steam::get_game_directory(1695793, dir)) {
6669
QString hrek = QString::fromWCharArray(dir.c_str());

0 commit comments

Comments
 (0)