2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Copyright (c) 1998-2000, Matthes Bender
|
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
|
|
|
* Copyright (c) 2009-2013, The OpenClonk Team and contributors
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
2009-05-08 13:28:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Drawing tools dialog for landscape editing in console mode */
|
|
|
|
|
|
|
|
#include <C4Include.h>
|
|
|
|
#include <C4ToolsDlg.h>
|
|
|
|
#include <C4Console.h>
|
2009-06-12 18:52:21 +00:00
|
|
|
#include <C4Texture.h>
|
|
|
|
#include <C4Landscape.h>
|
2009-06-15 22:06:37 +00:00
|
|
|
#include <C4GameControl.h>
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::Open()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
// Create dialog window
|
2010-12-11 18:50:38 +00:00
|
|
|
Console.ToolsDlgOpen(this);
|
2009-05-08 13:28:41 +00:00
|
|
|
Active = true;
|
|
|
|
// Update contols
|
|
|
|
InitGradeCtrl();
|
|
|
|
UpdateLandscapeModeCtrls();
|
|
|
|
UpdateToolCtrls();
|
|
|
|
UpdateIFTControls();
|
|
|
|
InitMaterialCtrls();
|
|
|
|
EnableControls();
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SetTool(int32_t iTool, bool fTemp)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
Tool=iTool;
|
2010-03-27 16:05:02 +00:00
|
|
|
if (!fTemp) SelectedTool = Tool;
|
2009-05-08 13:28:41 +00:00
|
|
|
UpdateToolCtrls();
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::InitMaterialCtrls()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
// Materials
|
2010-12-11 18:50:38 +00:00
|
|
|
Console.ToolsDlgInitMaterialCtrls(this);
|
2009-05-08 13:28:41 +00:00
|
|
|
// Textures
|
|
|
|
UpdateTextures();
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::SetMaterial(const char *szMaterial)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
SCopy(szMaterial,Material,C4M_MaxName);
|
|
|
|
AssertValidTexture();
|
|
|
|
EnableControls();
|
2009-06-05 15:20:41 +00:00
|
|
|
if (::Landscape.Mode==C4LSC_Static) UpdateTextures();
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::SetTexture(const char *szTexture)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2010-04-01 21:08:06 +00:00
|
|
|
// assert valid (for separator selection)
|
2009-06-05 15:09:54 +00:00
|
|
|
if (!::TextureMap.GetTexture(szTexture))
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
// ensure correct texture is in dlg
|
2010-12-11 18:50:38 +00:00
|
|
|
Console.ToolsDlgSetTexture(this, szTexture);
|
2009-05-08 13:28:41 +00:00
|
|
|
return;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
SCopy(szTexture,Texture,C4M_MaxName);
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SetIFT(bool fIFT)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
if (fIFT) ModeIFT = 1; else ModeIFT=0;
|
|
|
|
UpdateIFTControls();
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::SetColorPattern(const char *szMaterial, const char *szTexture)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SetGrade(int32_t iGrade)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2015-02-12 22:05:55 +00:00
|
|
|
Grade = Clamp(iGrade,C4TLS_GradeMin,C4TLS_GradeMax);
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
bool C4ToolsDlg::ChangeGrade(int32_t iChange)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2015-02-12 22:05:55 +00:00
|
|
|
Grade = Clamp(Grade+iChange,C4TLS_GradeMin,C4TLS_GradeMax);
|
2010-12-11 18:50:38 +00:00
|
|
|
NeedPreviewUpdate();
|
2009-05-08 13:28:41 +00:00
|
|
|
InitGradeCtrl();
|
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SetLandscapeMode(int32_t iMode, bool fThroughControl)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-06-05 15:20:41 +00:00
|
|
|
int32_t iLastMode=::Landscape.Mode;
|
2009-05-08 13:28:41 +00:00
|
|
|
// Exact to static: confirm data loss warning
|
|
|
|
if (iLastMode==C4LSC_Exact)
|
|
|
|
if (iMode==C4LSC_Static)
|
|
|
|
if (!fThroughControl)
|
2009-08-15 18:50:32 +00:00
|
|
|
if (!Console.Message(LoadResStr("IDS_CNS_EXACTTOSTATIC"),true))
|
|
|
|
return false;
|
2009-05-08 13:28:41 +00:00
|
|
|
// send as control
|
|
|
|
if (!fThroughControl)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-06-15 22:06:37 +00:00
|
|
|
::Control.DoInput(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_SetMode, iMode), CDT_Decide);
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
// Set landscape mode
|
2009-06-05 15:20:41 +00:00
|
|
|
::Landscape.SetMode(iMode);
|
2009-05-08 13:28:41 +00:00
|
|
|
// Exact to static: redraw landscape from map
|
|
|
|
if (iLastMode==C4LSC_Exact)
|
|
|
|
if (iMode==C4LSC_Static)
|
2009-06-05 15:20:41 +00:00
|
|
|
::Landscape.MapToLandscape();
|
2009-05-08 13:28:41 +00:00
|
|
|
// Assert valid tool
|
|
|
|
if (iMode!=C4LSC_Exact)
|
|
|
|
if (SelectedTool==C4TLS_Fill)
|
|
|
|
SetTool(C4TLS_Brush, false);
|
|
|
|
// Update controls
|
|
|
|
UpdateLandscapeModeCtrls();
|
|
|
|
EnableControls();
|
|
|
|
UpdateTextures();
|
|
|
|
// Success
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::AssertValidTexture()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
// Static map mode only
|
2009-06-05 15:20:41 +00:00
|
|
|
if (::Landscape.Mode!=C4LSC_Static) return;
|
2009-05-08 13:28:41 +00:00
|
|
|
// Ignore if sky
|
|
|
|
if (SEqual(Material,C4TLS_MatSky)) return;
|
|
|
|
// Current material-texture valid
|
2009-08-15 18:50:32 +00:00
|
|
|
if (::TextureMap.GetIndex(Material,Texture,false)) return;
|
2009-05-08 13:28:41 +00:00
|
|
|
// Find valid material-texture
|
|
|
|
const char *szTexture;
|
2010-01-25 04:00:59 +00:00
|
|
|
for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-08-15 18:50:32 +00:00
|
|
|
if (::TextureMap.GetIndex(Material,szTexture,false))
|
2009-05-08 13:28:41 +00:00
|
|
|
{ SelectTexture(szTexture); return; }
|
|
|
|
}
|
2010-03-28 18:58:01 +00:00
|
|
|
// No valid texture found
|
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SelectTexture(const char *szTexture)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2010-12-11 18:50:38 +00:00
|
|
|
Console.ToolsDlgSelectTexture(this, szTexture);
|
2009-05-08 13:28:41 +00:00
|
|
|
SetTexture(szTexture);
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool C4ToolsDlg::SelectMaterial(const char *szMaterial)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2010-12-11 18:50:38 +00:00
|
|
|
Console.ToolsDlgSetMaterial(this, szMaterial);
|
2009-05-08 13:28:41 +00:00
|
|
|
SetMaterial(szMaterial);
|
2009-08-15 18:50:32 +00:00
|
|
|
return true;
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::SetAlternateTool()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2010-03-27 16:05:02 +00:00
|
|
|
// alternate tool is the picker in any mode
|
|
|
|
SetTool(C4TLS_Picker, true);
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4ToolsDlg::ResetAlternateTool()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2010-03-27 16:05:02 +00:00
|
|
|
// reset tool to selected tool in case alternate tool was set
|
|
|
|
SetTool(SelectedTool, true);
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|