mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Compiled Linux version. The welcome screen doesn't display the icon images, and the buttons don't work. Data is found at *prefix*/Magic Set Editor/data and the images at *prefix*/Magic Set Editor/resource. On Ubuntu, *prefix* is /usr/local/share. Resource files are all the image files from resource. I haven't configured them, because I haven't made it past the welcome screen.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@188 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -88,8 +88,8 @@ Settings::Settings()
|
||||
, set_window_width (790)
|
||||
, set_window_height (300)
|
||||
, card_notes_height (40)
|
||||
, check_updates (CHECK_IF_CONNECTED)
|
||||
, updates_url (_("http://magicseteditor.sourceforge.net/updates"))
|
||||
, check_updates (CHECK_IF_CONNECTED)
|
||||
{}
|
||||
|
||||
void Settings::addRecentFile(const String& filename) {
|
||||
@@ -136,7 +136,7 @@ StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet
|
||||
/// Retrieve the directory to use for settings and other data files
|
||||
String user_settings_dir() {
|
||||
String dir = wxStandardPaths::Get().GetUserDataDir();
|
||||
if (!wxDirExists(dir)) wxMkDir(dir);
|
||||
if (!wxDirExists(dir)) wxMkDir(wxConvLocal.cWX2MB(dir), 0777);
|
||||
return dir + _("/");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void TextCtrl::setValue(String* value) {
|
||||
void TextCtrl::valueChanged() {
|
||||
if (!viewers.empty()) {
|
||||
TextValue& tv = static_cast<TextValue&>(*viewers.front()->getValue());
|
||||
tv.value.assign(value ? *value : wxEmptyString);
|
||||
tv.value.assign(value ? String(*value) : String(wxEmptyString));
|
||||
viewers.front()->onValueChange();
|
||||
}
|
||||
onChange();
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include "icon_menu.hpp"
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : generateDisabledImage
|
||||
|
||||
@@ -57,12 +58,14 @@ void IconMenu::Append(int id, const String& resource, const String& text, const
|
||||
item->SetBitmaps(bitmap, bitmap);
|
||||
item->SetDisabledBitmap(disabledImage);
|
||||
wxMenu::Append(item);
|
||||
#else
|
||||
|
||||
// load bitmap
|
||||
#else
|
||||
|
||||
// load bitmap
|
||||
|
||||
Bitmap bitmap = load_resource_image(resource);
|
||||
// add menu
|
||||
wxMenuItem* item = new wxMenuItem(this, id, text, help, style, submenu);
|
||||
// add menu
|
||||
item->SetBitmap(bitmap);
|
||||
wxMenu::Append(item);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <gui/symbol/point_editor.hpp>
|
||||
#include <gui/symbol/window.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <gfx/bezier.hpp>
|
||||
#include <data/action/symbol_part.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -23,10 +24,10 @@ SymbolPointEditor::SymbolPointEditor(SymbolControl* control, const SymbolPartP&
|
||||
, selection(SELECTED_NONE)
|
||||
, hovering(SELECTED_NONE)
|
||||
// Load gui stock
|
||||
, pointSelect(_("CUR_POINT"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, pointAdd (_("CUR_POINT_ADD"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, pointCurve (_("CUR_POINT_CURVE"),wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, pointMove (_("CUR_POINT_MOVE"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, pointSelect(load_resource_image(_("CUR_POINT")))
|
||||
, pointAdd (load_resource_image(_("CUR_POINT_ADD")))
|
||||
, pointCurve (load_resource_image(_("CUR_POINT_CURVE")))
|
||||
, pointMove (load_resource_image(_("CUR_POINT_MOVE")))
|
||||
{
|
||||
resetActions();
|
||||
// // fix pen joins
|
||||
@@ -526,6 +527,6 @@ SelectedHandle SymbolPointEditor::findHandle(const Vector2D& pos) {
|
||||
}
|
||||
|
||||
bool SymbolPointEditor::inRange(const Vector2D& a, const Vector2D& b, double range) {
|
||||
return abs(a.x - b.x) <= range &&
|
||||
abs(a.y - b.y) <= range;
|
||||
return fabs(a.x - b.x) <= range &&
|
||||
fabs(a.y - b.y) <= range;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
SymbolSelectEditor::SymbolSelectEditor(SymbolControl* control, bool rotate)
|
||||
: SymbolEditorBase(control)
|
||||
, rotate(rotate)
|
||||
, cursorRotate(_("CUR_ROTATE"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, cursorShearX(_("CUR_SHEAR_X"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, cursorShearY(_("CUR_SHEAR_Y"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
, cursorRotate(load_resource_image(_("CUR_ROTATE")))
|
||||
, cursorShearX(load_resource_image(_("CUR_SHEAR_X")))
|
||||
, cursorShearY(load_resource_image(_("CUR_SHEAR_Y")))
|
||||
{
|
||||
// Load resource images
|
||||
Image rot = load_resource_image(_("HANDLE_ROTATE"));
|
||||
|
||||
@@ -17,7 +17,7 @@ DECLARE_TYPEOF_COLLECTION(pair_ThumbnailRequestP_Image);
|
||||
String user_settings_dir();
|
||||
String image_cache_dir() {
|
||||
String dir = user_settings_dir() + _("/cache");
|
||||
if (!wxDirExists(dir)) wxMkDir(dir);
|
||||
if (!wxDirExists(dir)) wxMkDir(wxConvLocal.cWX2MB(dir), 0777);
|
||||
return dir + _("/");
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -9,13 +9,14 @@
|
||||
#include <gui/util.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/rotation.hpp>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/renderer.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#if wxUSE_UXTHEME && defined(__WXMSW__)
|
||||
#include <wx/msw/uxtheme.h>
|
||||
#include <tmschema.h>
|
||||
#include <shlobj.h>
|
||||
#include <wx/mstream.h>
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window related
|
||||
@@ -71,7 +72,7 @@ void draw_checker(RotatedDC& dc, const RealRect& rect) {
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
|
||||
Image load_resource_image(const String& name) {
|
||||
#ifdef __WXMSW__
|
||||
#if defined(__WXMSW__)
|
||||
// Load resource
|
||||
// based on wxLoadUserResource
|
||||
// The image can be in an IMAGE resource, in any file format
|
||||
@@ -87,6 +88,17 @@ Image load_resource_image(const String& name) {
|
||||
int len = ::SizeofResource(wxGetInstance(), hResource);
|
||||
wxMemoryInputStream stream(data, len);
|
||||
return wxImage(stream);
|
||||
#elif defined(__linux__)
|
||||
static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/");
|
||||
String file = path + name.Lower();
|
||||
wxImage resource (file + _(".png"), wxBITMAP_TYPE_PNG);
|
||||
if (!resource.Ok()) resource.LoadFile (file + _(".bmp"), wxBITMAP_TYPE_BMP);
|
||||
if (!resource.Ok()) resource.LoadFile (file + _(".ico"), wxBITMAP_TYPE_ICO);
|
||||
if (!resource.Ok()) resource.LoadFile (file + _(".cur"), wxBITMAP_TYPE_CUR);
|
||||
if (!resource.Ok()) throw InternalError(String::Format(_("Resource not found: %s"), name.c_str()));
|
||||
return resource;
|
||||
#else
|
||||
#error Handling of resource loading needs to be declared.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <gui/value/text.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/action/value.hpp>
|
||||
#include <util/tagged_string.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -258,7 +259,7 @@ wxCursor rotated_ibeam;
|
||||
wxCursor TextValueEditor::cursor() const {
|
||||
if (viewer.getRotation().sideways() ^ style().getRotation().sideways()) { // 90 or 270 degrees
|
||||
if (!rotated_ibeam.Ok()) {
|
||||
rotated_ibeam = wxCursor(_("CUR_ROT_IBEAM"));
|
||||
rotated_ibeam = wxCursor(load_resource_image(_("CUR_ROT_IBEAM")));
|
||||
}
|
||||
return rotated_ibeam;
|
||||
} else {
|
||||
|
||||
@@ -26,12 +26,12 @@ WelcomeWindow::WelcomeWindow()
|
||||
SetIcon(wxIcon(_("ICON_APP")));
|
||||
|
||||
// init controls
|
||||
wxButton* new_set = new HoverButtonExt(this, ID_FILE_NEW, _("WELCOME_NEW"), _BUTTON_("new set"), _HELP_("new set"));
|
||||
wxButton* open_set = new HoverButtonExt(this, ID_FILE_OPEN, _("WELCOME_OPEN"), _BUTTON_("open set"), _HELP_("open set"));
|
||||
wxButton* new_set = new HoverButtonExt(this, ID_FILE_NEW, load_resource_image(_("WELCOME_NEW")), _BUTTON_("new set"), _HELP_("new set"));
|
||||
wxButton* open_set = new HoverButtonExt(this, ID_FILE_OPEN, load_resource_image(_("WELCOME_OPEN")), _BUTTON_("open set"), _HELP_("open set"));
|
||||
wxButton* open_last = 0;
|
||||
if (!settings.recent_sets.empty()) {
|
||||
wxFileName n(settings.recent_sets.front());
|
||||
open_last = new HoverButtonExt(this, ID_FILE_RECENT, _("WELCOME_LAST"), _BUTTON_("last opened set"), _("Open '") + n.GetName() + _("'"));
|
||||
open_last = new HoverButtonExt(this, ID_FILE_RECENT, load_resource_image(_("WELCOME_LAST")), _BUTTON_("last opened set"), _("Open '") + n.GetName() + _("'"));
|
||||
}
|
||||
|
||||
wxSizer* s1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -105,19 +105,20 @@ END_EVENT_TABLE ()
|
||||
|
||||
// ----------------------------------------------------------------------------- : Hover button with label
|
||||
|
||||
HoverButtonExt::HoverButtonExt(Window* parent, int id, const String& icon_name, const String& label, const String& sub_label)
|
||||
HoverButtonExt::HoverButtonExt(Window* parent, int id, const wxImage& icon, const String& label, const String& sub_label)
|
||||
: HoverButton(parent, id, _("BTN"))
|
||||
, icon(load_resource_image(icon_name))
|
||||
, icon(icon)
|
||||
, label(label), sub_label(sub_label)
|
||||
, font_large(14, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial"))
|
||||
, font_small(8, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial"))
|
||||
{}
|
||||
|
||||
void HoverButtonExt::draw(DC& dc) {
|
||||
handle_error(Error(_("HEYA")));
|
||||
// draw button
|
||||
HoverButton::draw(dc);
|
||||
// icon
|
||||
if (icon.Ok()) dc.DrawBitmap(icon, 7, 7);
|
||||
if (icon.Ok()) dc.DrawBitmap(icon, 7, 7); else handle_error(Error(_("Error drawing button bitmaps")));
|
||||
// text
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
dc.SetFont(font_large);
|
||||
|
||||
@@ -51,7 +51,7 @@ class WelcomeWindow : public Frame {
|
||||
/// An extended hover button, not only has base images, but also has two labels
|
||||
class HoverButtonExt : public HoverButton {
|
||||
public:
|
||||
HoverButtonExt(Window* parent, int id, const String& icon_name, const String& label, const String& sub_label);
|
||||
HoverButtonExt(Window* parent, int id, const wxImage& icon_name, const String& label, const String& sub_label);
|
||||
|
||||
private:
|
||||
Bitmap icon;
|
||||
|
||||
@@ -392,8 +392,8 @@ bool equal(const ScriptValue& a, const ScriptValue& b) {
|
||||
// HACK for ScriptObject<shared_ptr<X> >
|
||||
// assumes different types are layed out the same, and that
|
||||
// should be void*, but then we need getMember for void
|
||||
const ScriptObject<int*>& av = reinterpret_cast<const ScriptObject<int*>&>(a);
|
||||
const ScriptObject<int*>& bv = reinterpret_cast<const ScriptObject<int*>&>(b);
|
||||
const ScriptObject<int*>& av = dynamic_cast<const ScriptObject<int*>&>(a);
|
||||
const ScriptObject<int*>& bv = dynamic_cast<const ScriptObject<int*>&>(b);
|
||||
return av.getValue() == bv.getValue();
|
||||
}
|
||||
return &a == &b;
|
||||
@@ -565,7 +565,7 @@ ScriptValueP ScriptBuildin_combined_editor::dependencies(Context& ctx, const Dep
|
||||
}
|
||||
}
|
||||
}
|
||||
SCRIPT_RETURN(dependency_dummy);
|
||||
return dependency_dummy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,22 +64,22 @@ void Script::addInstruction(InstructionType t) {
|
||||
// // optimize: push x ; member_v --> member x
|
||||
// instructions.back().instr = I_MEMBER;
|
||||
//} else {
|
||||
Instruction i = {t, 0};
|
||||
Instruction i = {t, {0}};
|
||||
instructions.push_back(i);
|
||||
//}
|
||||
}
|
||||
void Script::addInstruction(InstructionType t, unsigned int d) {
|
||||
Instruction i = {t, d};
|
||||
Instruction i = {t, {d}};
|
||||
instructions.push_back(i);
|
||||
}
|
||||
void Script::addInstruction(InstructionType t, const ScriptValueP& c) {
|
||||
constants.push_back(c);
|
||||
Instruction i = {t, (unsigned int)constants.size() - 1};
|
||||
Instruction i = {t, {(unsigned int)constants.size() - 1}};
|
||||
instructions.push_back(i);
|
||||
}
|
||||
void Script::addInstruction(InstructionType t, const String& s) {
|
||||
constants.push_back(toScript(s));
|
||||
Instruction i = {t, (unsigned int)constants.size() - 1};
|
||||
Instruction i = {t, {(unsigned int)constants.size() - 1}};
|
||||
instructions.push_back(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,6 @@ class Scriptable {
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
|
||||
// we need some custom io, because the behaviour is different for each of Reader/Writer/GetMember
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/io/get_member.hpp>
|
||||
class Context;
|
||||
class Dependency;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <script/value.hpp>
|
||||
#include <script/script.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : GetDefaultMember
|
||||
// ---------------------------------------------------------------------------- : GetDefaultMember
|
||||
|
||||
template <> void GetDefaultMember::handle(const Char* const& v) { value = toScript(v); }
|
||||
void GetDefaultMember::handle(const Char* v) { value = toScript(v); }
|
||||
template <> void GetDefaultMember::handle(const String& v) { value = toScript(v); }
|
||||
template <> void GetDefaultMember::handle(const FileName& v) { value = toScript(v); }
|
||||
template <> void GetDefaultMember::handle(const int& v) { value = toScript(v); }
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <script/value.hpp>
|
||||
|
||||
class Script;
|
||||
class ScriptValue;
|
||||
|
||||
DECLARE_INTRUSIVE_POINTER_TYPE(ScriptValue);
|
||||
DECLARE_INTRUSIVE_POINTER_TYPE(Script);
|
||||
@@ -39,13 +41,14 @@ class GetDefaultMember {
|
||||
/// Handle an object: we don't match things with a name
|
||||
template <typename T>
|
||||
void handle(const Char* name, const T& object) {}
|
||||
|
||||
|
||||
/// Handle an object: investigate children, or store it if we know how
|
||||
void handle(const Char *);
|
||||
template <typename T> void handle(const T&);
|
||||
|
||||
/// Handle a Defaultable: investigate children
|
||||
template <typename T> void handle(const Defaultable<T>&);
|
||||
template <typename T> void handle(const Scriptable<T>&);
|
||||
template <typename T> void handle(const Scriptable<T>& );
|
||||
template <typename T> void handle(const vector<T>& c) { value = toScript(&c); }
|
||||
template <typename K, typename V> void handle(const map<K,V>& c) { value = toScript(&c); }
|
||||
template <typename K, typename V> void handle(const IndexMap<K,V>& c) { value = toScript(&c); }
|
||||
|
||||
@@ -137,7 +137,7 @@ inline shared_ptr<T> new_shared7(const A0& a0, const A1& a1, const A2& a2, const
|
||||
|
||||
class IntrusivePtrBase {
|
||||
public:
|
||||
virtual ~IntrusivePtrBase();
|
||||
virtual ~IntrusivePtrBase() {};
|
||||
protected:
|
||||
/// Delete this object
|
||||
virtual void destroy() {
|
||||
|
||||
Reference in New Issue
Block a user