Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/orbweaver/master'
# Conflicts: # include/imap.h # radiant/ui/UserInterfaceModule.cpp # radiant/ui/einspector/EntityInspector.cpp # radiantcore/map/Map.cpp # radiantcore/map/Map.h
- Loading branch information
Showing
16 changed files
with
435 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include "math/Vector3.h" | ||
|
||
namespace map | ||
{ | ||
|
||
/// Parsed point positions from a .lin file | ||
class PointTrace | ||
{ | ||
public: | ||
using Points = std::vector<Vector3>; | ||
|
||
private: | ||
|
||
// List of point positions | ||
Points _points; | ||
|
||
public: | ||
|
||
/// Construct a PointTrace to read point data from the given stream | ||
explicit PointTrace(std::istream& stream) | ||
{ | ||
// Point file consists of one point per line, with three components | ||
double x, y, z; | ||
while (stream >> x >> y >> z) | ||
{ | ||
_points.push_back(Vector3(x, y, z)); | ||
} | ||
} | ||
|
||
/// Return points parsed | ||
const Points& points() const { return _points; } | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "PointFileChooser.h" | ||
|
||
#include "imainframe.h" | ||
#include "imap.h" | ||
#include "icommandsystem.h" | ||
#include "os/fs.h" | ||
#include "command/ExecutionFailure.h" | ||
|
||
#include <wx/frame.h> | ||
#include <wx/sizer.h> | ||
#include <wx/choice.h> | ||
#include <list> | ||
|
||
namespace ui | ||
{ | ||
|
||
PointFileChooser::PointFileChooser(const wxArrayString& files) | ||
: wxDialog(GlobalMainFrame().getWxTopLevelWindow(), wxID_ANY, | ||
"Choose pointfile") | ||
{ | ||
SetSizer(new wxBoxSizer(wxVERTICAL)); | ||
|
||
// Construct and populate the dropdown list | ||
_pfChoice.reset( | ||
new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, files) | ||
); | ||
_pfChoice->SetSelection(0); | ||
GetSizer()->Add(_pfChoice.get(), 0, wxEXPAND | wxALL, 12); | ||
|
||
// Add dialog buttons | ||
auto btnSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); | ||
GetSizer()->Add(btnSizer, 0, wxALIGN_RIGHT | wxALIGN_BOTTOM | wxBOTTOM, 12); | ||
|
||
Fit(); | ||
} | ||
|
||
void PointFileChooser::chooseAndToggle() | ||
{ | ||
// If the point trace is currently visible, toggle it to invisible and we're | ||
// done. | ||
if (GlobalMapModule().isPointTraceVisible()) | ||
{ | ||
GlobalMapModule().showPointFile({}); | ||
return; | ||
} | ||
|
||
// Determine the list of pointfiles | ||
std::vector<fs::path> pointfiles; | ||
GlobalMapModule().forEachPointfile([&](const fs::path& p) | ||
{ pointfiles.push_back(p); }); | ||
if (pointfiles.empty()) | ||
throw cmd::ExecutionFailure("No pointfiles found for current map."); | ||
|
||
// If there is a choice to make, show the dialog | ||
std::size_t chosenPointfile = 0; | ||
if (pointfiles.size() > 1) | ||
{ | ||
// Construct list of wxString filenames | ||
wxArrayString filenames; | ||
for (const fs::path& p: pointfiles) | ||
filenames.Add(static_cast<std::string>(p.filename())); | ||
|
||
// Show dialog with list of pointfiles | ||
PointFileChooser chooser(filenames); | ||
if (chooser.ShowModal() == wxID_OK) | ||
chosenPointfile = chooser._pfChoice->GetSelection(); | ||
else | ||
// Dialog cancelled, don't proceed to showing point trace | ||
return; | ||
} | ||
|
||
// Show the chosen (or only) pointfile | ||
if (chosenPointfile >= 0 && chosenPointfile < pointfiles.size()) | ||
GlobalMapModule().showPointFile(pointfiles[chosenPointfile]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <wx/dialog.h> | ||
#include <wx/choice.h> | ||
#include <wx/windowptr.h> | ||
|
||
namespace ui | ||
{ | ||
|
||
/// Selector dialog for pointfiles associated with the current map | ||
class PointFileChooser: public wxDialog | ||
{ | ||
// wxChoice containing the chosen pointfile | ||
wxWindowPtr<wxChoice> _pfChoice; | ||
|
||
// Dialog constructor | ||
PointFileChooser(const wxArrayString& files); | ||
|
||
public: | ||
|
||
/** | ||
* \brief Toggle pointfile visibility, showing the chooser if necessary. | ||
* | ||
* If there is only a single pointfile available, this method acts as a | ||
* simple visibility toggle. If there is more than one pointfile, the | ||
* chooser dialog will be shown before toggling visibility on. If there are | ||
* no pointfiles available, an error dialog will be shown. | ||
*/ | ||
static void chooseAndToggle(); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.