Removes ColourTester utility (needs update-workspaces).
Adds busy cursor to Atlas map generator. This was SVN commit r9987.
This commit is contained in:
parent
6d2ff5162e
commit
d605e85ae5
@ -802,7 +802,6 @@ function setup_atlas_packages()
|
||||
|
||||
atlas_src = {
|
||||
"ActorEditor",
|
||||
"ColourTester",
|
||||
"CustomControls/Buttons",
|
||||
"CustomControls/Canvas",
|
||||
"CustomControls/ColourDialog",
|
||||
@ -920,7 +919,6 @@ end
|
||||
|
||||
function setup_atlas_frontends()
|
||||
setup_atlas_frontend_package("ActorEditor")
|
||||
setup_atlas_frontend_package("ColourTester")
|
||||
if options["aoe3ed"] then
|
||||
setup_atlas_frontend_package("ArchiveViewer")
|
||||
setup_atlas_frontend_package("FileConverter")
|
||||
|
@ -769,7 +769,6 @@ function setup_atlas_projects()
|
||||
|
||||
atlas_src = {
|
||||
"ActorEditor",
|
||||
"ColourTester",
|
||||
"CustomControls/Buttons",
|
||||
"CustomControls/Canvas",
|
||||
"CustomControls/ColourDialog",
|
||||
@ -890,7 +889,6 @@ end
|
||||
|
||||
function setup_atlas_frontends()
|
||||
setup_atlas_frontend_project("ActorEditor")
|
||||
setup_atlas_frontend_project("ColourTester")
|
||||
if _OPTIONS["aoe3ed"] then
|
||||
setup_atlas_frontend_project("ArchiveViewer")
|
||||
setup_atlas_frontend_project("FileConverter")
|
||||
|
@ -1,43 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
// Use WinXP-style controls
|
||||
# if _MSC_VER >= 1400 // (can't be bothered to implement this for VC7.1...)
|
||||
# pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"")
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
#else
|
||||
int main()
|
||||
#endif
|
||||
{
|
||||
Atlas_StartWindow(L"ColourTester");
|
||||
return 0;
|
||||
}
|
@ -1 +0,0 @@
|
||||
IDI_ICON1 ICON "..\\AtlasUI\\Misc\\Graphics\\ColourTester.ico"
|
@ -8,10 +8,6 @@ my @progs = (
|
||||
PROJECT_NAME => "ActorEditor",
|
||||
WINDOW_NAME => "ActorEditor",
|
||||
},
|
||||
{
|
||||
PROJECT_NAME => "ColourTester",
|
||||
WINDOW_NAME => "ColourTester",
|
||||
},
|
||||
{
|
||||
PROJECT_NAME => "FileConverter",
|
||||
WINDOW_NAME => "FileConverter",
|
||||
|
@ -1,108 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "ColourTester.h"
|
||||
|
||||
#include "ColourTesterImageCtrl.h"
|
||||
#include "ColourTesterColourCtrl.h"
|
||||
#include "ColourTesterFileCtrl.h"
|
||||
|
||||
#include "wx/dnd.h"
|
||||
|
||||
DEFINE_EVENT_TYPE(wxEVT_MY_IMAGE_CHANGED)
|
||||
|
||||
BEGIN_EVENT_TABLE(ColourTester, wxFrame)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_MY_IMAGE_CHANGED, ColourTester::OnImageChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
// Allow drag-and-drop of files onto the window, as a convenient way of opening them
|
||||
class DropTarget : public wxFileDropTarget
|
||||
{
|
||||
public:
|
||||
DropTarget(ColourTesterImageCtrl* imgctrl)
|
||||
: m_ImageCtrl(imgctrl)
|
||||
{}
|
||||
|
||||
bool OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxArrayString& filenames)
|
||||
{
|
||||
if (filenames.GetCount() >= 1)
|
||||
m_ImageCtrl->SetImageFile(filenames[0]);
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
ColourTesterImageCtrl* m_ImageCtrl;
|
||||
};
|
||||
|
||||
|
||||
ColourTester::ColourTester(wxWindow* parent)
|
||||
: wxFrame(parent, wxID_ANY, _("Colour Tester"), wxDefaultPosition, wxSize(800, 700))
|
||||
{
|
||||
SetIcon(wxIcon(_T("ICON_ColourTester")));
|
||||
|
||||
wxPanel* mainPanel = new wxPanel(this);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set up sizers:
|
||||
|
||||
wxBoxSizer* vertSizer = new wxBoxSizer(wxVERTICAL);
|
||||
mainPanel->SetSizer(vertSizer);
|
||||
|
||||
wxBoxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
vertSizer->Add(topSizer,
|
||||
wxSizerFlags().Proportion(1).Expand().Border(wxLEFT|wxRIGHT, 5));
|
||||
|
||||
wxBoxSizer* bottomSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
vertSizer->Add(bottomSizer,
|
||||
wxSizerFlags().Expand().Border(wxLEFT|wxRIGHT, 5));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Add things to sizers:
|
||||
|
||||
m_ImageCtrl = new ColourTesterImageCtrl(mainPanel);
|
||||
|
||||
topSizer->Add(new ColourTesterFileCtrl(mainPanel, wxSize(200,200), m_ImageCtrl),
|
||||
wxSizerFlags().Expand().Border(wxALL, 10));
|
||||
|
||||
topSizer->Add(m_ImageCtrl,
|
||||
wxSizerFlags().Proportion(1).Expand().Border(wxALL, 10));
|
||||
|
||||
bottomSizer->Add((wxPanel*)new ColourTesterColourCtrl(mainPanel, m_ImageCtrl),
|
||||
wxSizerFlags().Border(wxALL, 10));
|
||||
|
||||
m_StatusBar = new wxStatusBar(mainPanel, wxID_ANY);
|
||||
m_StatusBar->SetFieldsCount(2);
|
||||
int statusWidths[] = { -2, -1 };
|
||||
m_StatusBar->SetStatusWidths(2, statusWidths);
|
||||
vertSizer->Add(m_StatusBar,
|
||||
wxSizerFlags().Expand());
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SetDropTarget(new DropTarget(m_ImageCtrl));
|
||||
|
||||
}
|
||||
|
||||
void ColourTester::OnImageChanged(wxCommandEvent& event)
|
||||
{
|
||||
ColourTesterImageCtrl* imgCtrl = wxDynamicCast(event.GetEventObject(), ColourTesterImageCtrl);
|
||||
wxCHECK(imgCtrl, );
|
||||
m_StatusBar->SetStatusText(event.GetString(), 0);
|
||||
m_StatusBar->SetStatusText(imgCtrl->GetImageFiletype(), 1);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class ColourTesterImageCtrl;
|
||||
|
||||
DECLARE_EVENT_TYPE(wxEVT_MY_IMAGE_CHANGED, -1);
|
||||
|
||||
class ColourTester : public wxFrame
|
||||
{
|
||||
public:
|
||||
ColourTester(wxWindow* parent);
|
||||
|
||||
private:
|
||||
void OnImageChanged(wxCommandEvent& event);
|
||||
|
||||
ColourTesterImageCtrl* m_ImageCtrl;
|
||||
|
||||
wxStatusBar* m_StatusBar;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
@ -1,123 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "ColourTesterColourCtrl.h"
|
||||
|
||||
#include "ColourTesterImageCtrl.h"
|
||||
#include "General/Datafile.h"
|
||||
|
||||
#include "wx/colordlg.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// A couple of buttons:
|
||||
|
||||
class ColouredButton : public wxButton
|
||||
{
|
||||
public:
|
||||
ColouredButton(wxWindow* parent, const wxColour& colour, const wxColour& textColor,
|
||||
const wxString& caption, ColourTesterImageCtrl* imgctrl)
|
||||
: wxButton(parent, wxID_ANY, caption),
|
||||
m_ImageCtrl(imgctrl), m_Colour(colour)
|
||||
{
|
||||
SetBackgroundColour(m_Colour);
|
||||
SetForegroundColour(textColor);
|
||||
}
|
||||
void OnButton(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_ImageCtrl->SetColour(m_Colour);
|
||||
}
|
||||
private:
|
||||
wxColour m_Colour;
|
||||
ColourTesterImageCtrl* m_ImageCtrl;
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(ColouredButton, wxButton)
|
||||
EVT_BUTTON(wxID_ANY, ColouredButton::OnButton)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
class CustomColourButton : public wxButton
|
||||
{
|
||||
public:
|
||||
CustomColourButton(wxWindow* parent, const wxString& caption, ColourTesterImageCtrl* imgctrl)
|
||||
: wxButton(parent, wxID_ANY, caption),
|
||||
m_ImageCtrl(imgctrl), m_Colour(127,127,127)
|
||||
{
|
||||
SetBackgroundColour(m_Colour);
|
||||
}
|
||||
void OnButton(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxColour c = wxGetColourFromUser(this, m_Colour);
|
||||
if (c.IsOk())
|
||||
{
|
||||
m_Colour = c;
|
||||
m_ImageCtrl->SetColour(m_Colour);
|
||||
SetBackgroundColour(m_Colour);
|
||||
}
|
||||
}
|
||||
private:
|
||||
wxColour m_Colour;
|
||||
ColourTesterImageCtrl* m_ImageCtrl;
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(CustomColourButton, wxButton)
|
||||
EVT_BUTTON(wxID_ANY, CustomColourButton::OnButton)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ColourTesterColourCtrl::ColourTesterColourCtrl(wxWindow* parent, ColourTesterImageCtrl* imgctrl)
|
||||
: wxPanel(parent, wxID_ANY)
|
||||
{
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxGridSizer* presetColourSizer = new wxGridSizer(2);
|
||||
mainSizer->Add(presetColourSizer);
|
||||
|
||||
AtObj colours (Datafile::ReadList("playercolours"));
|
||||
for (AtIter c = colours["colour"]; c.defined(); ++c)
|
||||
{
|
||||
wxColour back;
|
||||
{
|
||||
int r,g,b;
|
||||
std::wstringstream s;
|
||||
s << (std::wstring)c["@rgb"];
|
||||
s >> r >> g >> b;
|
||||
back = wxColour(r,g,b);
|
||||
}
|
||||
|
||||
wxColour text (0, 0, 0);
|
||||
if (c["@buttontext"].defined())
|
||||
{
|
||||
int r,g,b;
|
||||
std::wstringstream s;
|
||||
s << (std::wstring)c["@buttontext"];
|
||||
s >> r >> g >> b;
|
||||
text = wxColour(r,g,b);
|
||||
}
|
||||
presetColourSizer->Add(new ColouredButton(this, back, text, (wxString)c["@name"], imgctrl));
|
||||
}
|
||||
|
||||
presetColourSizer->Add(new CustomColourButton(this, _("Custom"), imgctrl));
|
||||
|
||||
SetSizer(mainSizer);
|
||||
mainSizer->SetSizeHints(this);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class ColourTesterImageCtrl;
|
||||
|
||||
class ColourTesterColourCtrl : public wxPanel
|
||||
{
|
||||
public:
|
||||
ColourTesterColourCtrl(wxWindow* parent, ColourTesterImageCtrl* imgctrl);
|
||||
};
|
@ -1,55 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "ColourTesterFileCtrl.h"
|
||||
|
||||
#include "General/Datafile.h"
|
||||
#include "ColourTesterImageCtrl.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(ColourTesterFileCtrl, wxVirtualDirTreeCtrl)
|
||||
EVT_TREE_SEL_CHANGED(wxID_ANY, ColourTesterFileCtrl::OnSelChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ColourTesterFileCtrl::ColourTesterFileCtrl(wxWindow* parent, const wxSize& size, ColourTesterImageCtrl* imgctrl)
|
||||
: wxVirtualDirTreeCtrl(parent, wxID_ANY, wxDefaultPosition, size),
|
||||
m_ImageCtrl(imgctrl)
|
||||
{
|
||||
wxFileName path (_T("mods/public/art/textures/skins/"));
|
||||
path.MakeAbsolute(Datafile::GetDataDirectory());
|
||||
wxASSERT(path.IsOk());
|
||||
SetRootPath(path.GetPath());
|
||||
}
|
||||
|
||||
void ColourTesterFileCtrl::OnSelChanged(wxTreeEvent& event)
|
||||
{
|
||||
if (IsFileNode(event.GetItem()))
|
||||
{
|
||||
m_ImageCtrl->SetImageFile(GetFullPath(event.GetItem()));
|
||||
}
|
||||
}
|
||||
|
||||
bool ColourTesterFileCtrl::OnAddDirectory(VdtcTreeItemBase &item, const wxFileName &WXUNUSED(name))
|
||||
{
|
||||
// Ignore .svn directories
|
||||
if (item.GetName() == _T(".svn"))
|
||||
return false;
|
||||
|
||||
// Accept everything else
|
||||
return true;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "VirtualDirTreeCtrl/virtualdirtreectrl.h"
|
||||
|
||||
// wxGenericDirCtrl could potentially be used instead of this; but it gets
|
||||
// indented a long way (since its root is far further back than necessary),
|
||||
// and its icons aren't very pretty, and it'd be hard to adjust it to use VFS.
|
||||
|
||||
class ColourTesterImageCtrl;
|
||||
|
||||
class ColourTesterFileCtrl : public wxVirtualDirTreeCtrl
|
||||
{
|
||||
public:
|
||||
ColourTesterFileCtrl(wxWindow* parent, const wxSize& size, ColourTesterImageCtrl* imgctrl);
|
||||
|
||||
virtual bool OnAddDirectory(VdtcTreeItemBase &item, const wxFileName &name);
|
||||
|
||||
private:
|
||||
void OnSelChanged(wxTreeEvent& event);
|
||||
|
||||
ColourTesterImageCtrl* m_ImageCtrl;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
@ -1,167 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "ColourTesterImageCtrl.h"
|
||||
|
||||
#include "ColourTester.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# ifndef NDEBUG
|
||||
# pragma comment(lib, "DevIL_DBG.lib")
|
||||
# pragma comment(lib, "DevILU_DBG.lib")
|
||||
# else
|
||||
# pragma comment(lib, "DevIL.lib")
|
||||
# pragma comment(lib, "DevILU.lib")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "IL/il.h"
|
||||
#include "IL/ilu.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(ColourTesterImageCtrl, wxWindow)
|
||||
EVT_PAINT(ColourTesterImageCtrl::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ColourTesterImageCtrl::ColourTesterImageCtrl(wxWindow* parent)
|
||||
: wxWindow(parent, wxID_ANY),
|
||||
m_Valid(false), m_ZoomAmount(1)
|
||||
{
|
||||
m_Colour[0] = 255;
|
||||
m_Colour[1] = 0;
|
||||
m_Colour[2] = 0;
|
||||
ilInit();
|
||||
ilGenImages(1, (ILuint*)&m_OriginalImage);
|
||||
ilSetInteger(IL_KEEP_DXTC_DATA, IL_TRUE);
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::SetImageFile(const wxFileName& fn)
|
||||
{
|
||||
ilBindImage(m_OriginalImage);
|
||||
|
||||
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
|
||||
ilEnable(IL_ORIGIN_SET);
|
||||
if (! ilLoadImage((wchar_t*)fn.GetFullPath().c_str()))
|
||||
{
|
||||
m_Valid = false;
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
m_Valid = true;
|
||||
|
||||
m_DxtcFormat = ilGetInteger(IL_DXTC_DATA_FORMAT);
|
||||
|
||||
ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
|
||||
|
||||
// TODO: Check for IL errors
|
||||
|
||||
{
|
||||
// I'm too lazy to add zoom buttons, so just use 2x zoom for <=256x256 images
|
||||
ILinfo info;
|
||||
iluGetImageInfo(&info);
|
||||
if (info.Width <= 256 && info.Height <= 256)
|
||||
m_ZoomAmount = 2;
|
||||
else
|
||||
m_ZoomAmount = 1;
|
||||
}
|
||||
|
||||
CalculateImage();
|
||||
|
||||
// Send an event to indicate that the image has changed, so that
|
||||
// the status-bar text can be updated
|
||||
wxCommandEvent evt(wxEVT_MY_IMAGE_CHANGED);
|
||||
evt.SetEventObject(this);
|
||||
evt.SetString(fn.GetFullPath());
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
}
|
||||
|
||||
wxString ColourTesterImageCtrl::GetImageFiletype()
|
||||
{
|
||||
wxString fmt = _("Not DXTC");
|
||||
switch (ilGetInteger(IL_DXTC_DATA_FORMAT)) {
|
||||
case IL_DXT1: fmt = _T("DXT1"); break;
|
||||
case IL_DXT2: fmt = _T("DXT2"); break;
|
||||
case IL_DXT3: fmt = _T("DXT3"); break;
|
||||
case IL_DXT4: fmt = _T("DXT4"); break;
|
||||
case IL_DXT5: fmt = _T("DXT5"); break;
|
||||
}
|
||||
return wxString::Format(_T("%s - %dx%d"), fmt.c_str(), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT));
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::SetColour(const wxColour& colour)
|
||||
{
|
||||
m_Colour[0] = colour.Red();
|
||||
m_Colour[1] = colour.Green();
|
||||
m_Colour[2] = colour.Blue();
|
||||
|
||||
CalculateImage();
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::SetZoom(int amount)
|
||||
{
|
||||
m_ZoomAmount = amount;
|
||||
CalculateImage();
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::CalculateImage()
|
||||
{
|
||||
if (! m_Valid)
|
||||
return;
|
||||
|
||||
ilBindImage(m_OriginalImage);
|
||||
|
||||
ILubyte* data = ilGetData();
|
||||
ILinfo info;
|
||||
iluGetImageInfo(&info);
|
||||
|
||||
wxASSERT(info.Bpp == 4);
|
||||
|
||||
unsigned char* newData = (unsigned char*)malloc(info.Width*info.Height*3);
|
||||
// wxImage desires malloc, not new[]
|
||||
|
||||
for (ILubyte *p0 = data, *p1 = newData;
|
||||
p0 < data+info.Width*info.Height*4;
|
||||
p0 += 4, p1 += 3)
|
||||
{
|
||||
// Interpolate between texture and texture*colour, so
|
||||
// new = old*alpha + old*colour*(1-alpha)
|
||||
float alpha = p0[3]/255.f;
|
||||
p1[0] = p0[0]*alpha + p0[0]*m_Colour[0]*(1.f-alpha)/255.f;
|
||||
p1[1] = p0[1]*alpha + p0[1]*m_Colour[1]*(1.f-alpha)/255.f;
|
||||
p1[2] = p0[2]*alpha + p0[2]*m_Colour[2]*(1.f-alpha)/255.f;
|
||||
}
|
||||
|
||||
m_FinalImage.SetData(newData, info.Width, info.Height);
|
||||
|
||||
if (m_ZoomAmount != 1)
|
||||
m_FinalImage = m_FinalImage.Scale(info.Width*m_ZoomAmount, info.Height*m_ZoomAmount);
|
||||
|
||||
m_FinalBitmap = wxBitmap(m_FinalImage);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
dc.Clear();
|
||||
|
||||
if (m_Valid && m_FinalBitmap.Ok())
|
||||
dc.DrawBitmap(m_FinalBitmap, 0, 0);
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* 0 A.D. 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
class ColourTesterImageCtrl : public wxWindow
|
||||
{
|
||||
public:
|
||||
ColourTesterImageCtrl(wxWindow* parent);
|
||||
|
||||
void SetImageFile(const wxFileName& fn);
|
||||
void SetColour(const wxColour& colour);
|
||||
void SetZoom(int amount);
|
||||
wxString GetImageFiletype();
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
private:
|
||||
void CalculateImage();
|
||||
|
||||
bool m_Valid; // stores whether a valid image is loaded and displayable
|
||||
unsigned int m_OriginalImage; // DevIL image id
|
||||
unsigned int m_DxtcFormat;
|
||||
wxImage m_FinalImage;
|
||||
wxBitmap m_FinalBitmap;
|
||||
|
||||
unsigned char m_Colour[3]; // RGB bytes
|
||||
|
||||
int m_ZoomAmount;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "ActorEditor/ActorEditor.h"
|
||||
#include "ArchiveViewer/ArchiveViewer.h"
|
||||
#include "ColourTester/ColourTester.h"
|
||||
#include "FileConverter/FileConverter.h"
|
||||
#include "ScenarioEditor/ScenarioEditor.h"
|
||||
#include "ErrorReporter/ErrorReporter.h"
|
||||
@ -206,7 +205,6 @@ public:
|
||||
wxFrame* frame;
|
||||
#define MAYBE(t) if (g_InitialWindowType == _T(#t)) frame = new t(NULL); else
|
||||
MAYBE(ActorEditor)
|
||||
MAYBE(ColourTester)
|
||||
#ifdef USE_AOE3ED
|
||||
MAYBE(ArchiveViewer)
|
||||
MAYBE(FileConverter)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
@ -1,5 +1,4 @@
|
||||
ICON_ActorEditor ICON "Graphics\\ActorEditor.ico"
|
||||
ICON_ColourTester ICON "Graphics\\ColourTester.ico"
|
||||
ICON_ArchiveViewer ICON "Graphics\\ArchiveViewer.ico"
|
||||
ICON_FileConverter ICON "Graphics\\FileConverter.ico"
|
||||
ICON_ScenarioEditor ICON "Graphics\\ScenarioEditor.ico"
|
||||
|
@ -479,6 +479,7 @@ void MapSidebar::OnRandomGenerate(wxCommandEvent& WXUNUSED(evt))
|
||||
std::string json = AtlasObject::SaveToJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), settings);
|
||||
|
||||
wxBusyInfo(_("Generating map"));
|
||||
wxBusyCursor busyc;
|
||||
|
||||
wxString scriptName(settings["Script"]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user