Qt Editor: Add "Static Flat" landscape mode

qteditor
Sven Eberhardt 2016-06-17 18:44:59 -04:00
parent ec6998e530
commit 25fa57cabf
15 changed files with 70 additions and 20 deletions

View File

@ -356,6 +356,7 @@ IDS_DLG_SELALL=Alles markieren
IDS_DLG_SOUND=Sound
IDS_DLG_STARTGAME=&Spiel starten
IDS_DLG_STATIC=Statische Landschaft
IDS_DLG_STATICFLAT=Statische Landschaft mit geraden Kanten
IDS_DLG_TOOLS=Landschaftswerkzeuge
IDS_DLG_VERSION=Version %s
IDS_DLG_VOTING=Abstimmung

View File

@ -356,6 +356,7 @@ IDS_DLG_SELALL=Select all
IDS_DLG_SOUND=Sound
IDS_DLG_STARTGAME=&Start Game
IDS_DLG_STATIC=Static landscape
IDS_DLG_STATICFLAT=Static landscape with flat borders
IDS_DLG_TOOLS=Landscape tools
IDS_DLG_VERSION=Version %s
IDS_DLG_VOTING=Voting

View File

@ -1419,7 +1419,7 @@ void C4ControlEMDrawTool::Execute() const
// set new mode
if (eAction == EMDT_SetMode)
{
Console.ToolsDlg.SetLandscapeMode(iMode, true);
Console.ToolsDlg.SetLandscapeMode(iMode, iX==1, true);
return;
}
// check current mode

View File

@ -1589,17 +1589,17 @@ void C4ConsoleGUI::State::OnNetClient(GtkWidget* item, gpointer data)
void C4ToolsDlg::State::OnButtonModeDynamic(GtkWidget* widget, gpointer data)
{
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Dynamic);
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Dynamic, false);
}
void C4ToolsDlg::State::OnButtonModeStatic(GtkWidget* widget, gpointer data)
{
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Static);
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Static, false);
}
void C4ToolsDlg::State::OnButtonModeExact(GtkWidget* widget, gpointer data)
{
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Exact);
static_cast<C4ToolsDlg::State*>(data)->GetOwner()->SetLandscapeMode(LandscapeMode::Exact, false);
}
void C4ToolsDlg::State::OnButtonBrush(GtkWidget* widget, gpointer data)

View File

@ -235,7 +235,7 @@ void C4ConsoleGUI::DoEnableControls(bool fEnable)
{
if (!Active) return;
state->SetEnabled(fEnable);
state->SetLandscapeMode(::Landscape.GetMode()); // initial setting
state->SetLandscapeMode(::Landscape.GetMode(), ::Game.C4S.Landscape.FlatChunkShapes); // initial setting
}
bool C4ConsoleGUI::DoUpdateHaltCtrls(bool fHalt)
@ -396,7 +396,7 @@ void C4ToolsDlg::UpdateIFTControls() { /* not using IFT */ }
void C4ToolsDlg::UpdateLandscapeModeCtrls()
{
// Update button down states for landscape mode
if (::Console.Active) ::Console.state->SetLandscapeMode(::Landscape.GetMode());
if (::Console.Active) ::Console.state->SetLandscapeMode(::Landscape.GetMode(), ::Game.C4S.Landscape.FlatChunkShapes);
}

View File

@ -640,6 +640,7 @@
<addaction name="actionCursorPicker"/>
<addaction name="separator"/>
<addaction name="actionDynamicLandscape"/>
<addaction name="actionStaticFlatLandscape"/>
<addaction name="actionStaticLandscape"/>
<addaction name="actionExactLandscape"/>
<addaction name="separator"/>
@ -952,6 +953,21 @@
<string>Ctrl+N</string>
</property>
</action>
<action name="actionStaticFlatLandscape">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/editor/res/StaticFlat_Trans.png</normaloff>:/editor/res/StaticFlat_Trans.png</iconset>
</property>
<property name="text">
<string>MAP_STATICFLAT</string>
</property>
<property name="toolTip">
<string>MAP_STATICFLAT_TIP</string>
</property>
</action>
</widget>
<resources>
<include location="resource.qrc"/>
@ -1501,6 +1517,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionStaticFlatLandscape</sender>
<signal>triggered(bool)</signal>
<receiver>MainWindow</receiver>
<slot>StaticFlatLandscapePressed(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
<y>312</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>PlayPressed(bool)</slot>
@ -1536,5 +1568,6 @@
<slot>AscendPropertyPath()</slot>
<slot>AddArrayElement()</slot>
<slot>RemoveArrayElement()</slot>
<slot>StaticFlatLandscapePressed(bool)</slot>
</slots>
</ui>

View File

@ -236,7 +236,7 @@ void C4ConsoleQtMainWindow::CursorPickerPressed(bool down)
void C4ConsoleQtMainWindow::DynamicLandscapePressed(bool down)
{
if (down)
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Dynamic);
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Dynamic, false);
else // cannot un-check by pressing again
state->ui.actionDynamicLandscape->setChecked(true);
}
@ -244,15 +244,23 @@ void C4ConsoleQtMainWindow::DynamicLandscapePressed(bool down)
void C4ConsoleQtMainWindow::StaticLandscapePressed(bool down)
{
if (down)
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Static);
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Static, false);
else // cannot un-check by pressing again
state->ui.actionStaticLandscape->setChecked(true);
}
void C4ConsoleQtMainWindow::StaticFlatLandscapePressed(bool down)
{
if (down)
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Static, true);
else // cannot un-check by pressing again
state->ui.actionStaticFlatLandscape->setChecked(true);
}
void C4ConsoleQtMainWindow::ExactLandscapePressed(bool down)
{
if (down)
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Exact);
::Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Exact, false);
else // cannot un-check by pressing again
state->ui.actionExactLandscape->setChecked(true);
}
@ -417,7 +425,7 @@ void C4ConsoleQtMainWindow::WelcomeLinkActivated(const QString &link)
/* Common C4ConsoleGUI interface */
C4ConsoleGUIState::C4ConsoleGUIState(C4ConsoleGUI *console) : viewport_area(NULL),
enabled(false), recording(false), net_enabled(false), landscape_mode(LandscapeMode::Dynamic),
enabled(false), recording(false), net_enabled(false), landscape_mode(LandscapeMode::Dynamic), flat_chunk_shapes(false),
editcursor_mode(C4CNS_ModePlay), drawing_tool(C4TLS_Brush), is_object_selection_updating(0)
{
}
@ -573,6 +581,7 @@ void C4ConsoleGUIState::UpdateActionStates()
ui.actionCursorFill->setEnabled(has_exact_draw_tools);
ui.actionDynamicLandscape->setEnabled(enabled);
ui.actionStaticLandscape->setEnabled(enabled);
ui.actionStaticFlatLandscape->setEnabled(enabled);
ui.actionExactLandscape->setEnabled(enabled);
ui.foregroundMatTexComboBox->setEnabled(is_drawing);
ui.backgroundMatTexComboBox->setEnabled(is_drawing);
@ -598,7 +607,8 @@ void C4ConsoleGUIState::UpdateActionStates()
ui.actionCursorFill->setChecked((editcursor_mode == C4CNS_ModeDraw) && (drawing_tool == C4TLS_Fill));
ui.actionCursorPicker->setChecked((editcursor_mode == C4CNS_ModeDraw) && (drawing_tool == C4TLS_Picker));
ui.actionDynamicLandscape->setChecked(landscape_mode == LandscapeMode::Dynamic);
ui.actionStaticLandscape->setChecked(landscape_mode == LandscapeMode::Static);
ui.actionStaticLandscape->setChecked(landscape_mode == LandscapeMode::Static && !flat_chunk_shapes);
ui.actionStaticFlatLandscape->setChecked(landscape_mode == LandscapeMode::Static && flat_chunk_shapes);
ui.actionExactLandscape->setChecked(landscape_mode == LandscapeMode::Exact);
ui.actionFileRecord->setChecked(recording);
}

View File

@ -104,6 +104,7 @@ public slots:
void CursorPickerPressed(bool down);
void DynamicLandscapePressed(bool down);
void StaticLandscapePressed(bool down);
void StaticFlatLandscapePressed(bool down);
void ExactLandscapePressed(bool down);
void DrawSizeChanged(int newval);
// File menu
@ -170,6 +171,7 @@ public:
// If other C4Console implementations are removed, the state could be merged and these members removed.
bool enabled, recording, net_enabled;
LandscapeMode landscape_mode;
bool flat_chunk_shapes;
int32_t editcursor_mode, drawing_tool;
StdCopyStrBuf material, texture, back_material, back_texture;
@ -188,7 +190,7 @@ public:
void UpdateBackMatTex();
// Set modes and tools
void SetEnabled(bool to_enabled) { enabled = to_enabled; UpdateActionStates(); if (enabled) ReInitDefinitions(); }
void SetLandscapeMode(LandscapeMode to_landscape_mode) { landscape_mode = to_landscape_mode; UpdateActionStates(); }
void SetLandscapeMode(LandscapeMode to_landscape_mode, bool to_flat_chunk_shapes) { landscape_mode = to_landscape_mode; flat_chunk_shapes = to_flat_chunk_shapes; UpdateActionStates(); }
void SetEditCursorMode(int32_t to_editcursor_mode) { editcursor_mode = to_editcursor_mode; UpdateActionStates(); }
void SetDrawingTool(int32_t to_drawing_tool) { drawing_tool = to_drawing_tool; UpdateActionStates(); }
void SetMaterial(const char *new_material) { material.Copy(new_material); UpdateMatTex(); }

View File

@ -631,15 +631,15 @@ INT_PTR CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
return true;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case IDC_BUTTONMODEDYNAMIC:
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Dynamic);
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Dynamic, false);
return true;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case IDC_BUTTONMODESTATIC:
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Static);
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Static, false);
return true;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case IDC_BUTTONMODEEXACT:
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Exact);
Console.ToolsDlg.SetLandscapeMode(LandscapeMode::Exact, false);
return true;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case IDC_BUTTONBRUSH:

View File

@ -160,7 +160,7 @@ int indexFromSender(id sender)
- (IBAction) selectLandscapeMode:(id)sender
{
// add one since 0 is "undefined"
Console.ToolsDlg.SetLandscapeMode((LandscapeMode)([sender selectedSegment]+1), NO);
Console.ToolsDlg.SetLandscapeMode((LandscapeMode)([sender selectedSegment]+1), NO, NO);
}
- (IBAction) setGrade:(id)sender

View File

@ -177,9 +177,10 @@ bool C4ToolsDlg::ChangeGrade(int32_t iChange)
return true;
}
bool C4ToolsDlg::SetLandscapeMode(LandscapeMode mode, bool fThroughControl)
bool C4ToolsDlg::SetLandscapeMode(LandscapeMode mode, bool flat_chunk_shapes, bool fThroughControl)
{
auto last_mode = ::Landscape.GetMode();
auto last_flat_chunk_shapes = ::Game.C4S.Landscape.FlatChunkShapes;
// Exact to static: confirm data loss warning
if (last_mode == LandscapeMode::Exact)
if (mode == LandscapeMode::Static)
@ -189,13 +190,14 @@ bool C4ToolsDlg::SetLandscapeMode(LandscapeMode mode, bool fThroughControl)
// send as control
if (!fThroughControl)
{
::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, mode), CDT_Decide);
::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, mode, flat_chunk_shapes ? 1 : 0), CDT_Decide);
return true;
}
// Set landscape mode
::Game.C4S.Landscape.FlatChunkShapes = flat_chunk_shapes;
::Landscape.SetMode(mode);
// Exact to static: redraw landscape from map
if (last_mode == LandscapeMode::Exact)
if (last_mode == LandscapeMode::Exact || (last_flat_chunk_shapes != flat_chunk_shapes))
if (mode == LandscapeMode::Static)
::Landscape.MapToLandscape();
// Assert valid tool

View File

@ -72,7 +72,7 @@ public:
bool SetGrade(int32_t iGrade);
bool SetTool(int32_t iTool, bool fTemp);
bool ToggleTool() { return !!SetTool((Tool+1)%4, false); }
bool SetLandscapeMode(LandscapeMode iMode, bool fThroughControl=false);
bool SetLandscapeMode(LandscapeMode iMode, bool flat_chunk_shapes, bool fThroughControl=false);
bool SetIFT(bool fIFT);
bool ToggleIFT() { return !!SetIFT(!ModeIFT); }
bool SelectTexture(const char *szTexture, bool by_console_gui=false);

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/editor">
<file>../res/StaticFlat_Trans.png</file>
<file>../res/CreateObj_Trans.png</file>
<file>../res/Brush_Trans.png</file>
<file>../res/Cursor_Trans.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 B

After

Width:  |  Height:  |  Size: 223 B