# Made Atlas compile on linux
graphics: basic terrain passibility atlas: lots of changes to make atlas compile under linux unix/X: more clipboard support - copy from 0AD to other programs unix/debug: use sys_get_executable_name instead of hard-coded paths ... and lots of other misc. changes This was SVN commit r4640.
This commit is contained in:
parent
05c9525fdc
commit
db045c330b
@ -7,6 +7,7 @@ class CObjectBase;
|
||||
struct SPropPoint;
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "ps/CStr.h"
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include "simulation/EntityManager.h"
|
||||
#include "simulation/Entity.h"
|
||||
|
||||
#include "TerrainProperties.h"
|
||||
#include "TextureEntry.h"
|
||||
#include "TextureManager.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "Terrain.h"
|
||||
#include "Patch.h"
|
||||
@ -89,10 +93,13 @@ bool CTerrain::isOnMap(const CVector2D& v) const
|
||||
return isOnMap(v.x, v.y);
|
||||
}
|
||||
|
||||
bool CTerrain::isPassable(const CVector2D &tileSpaceLoc) const
|
||||
bool CTerrain::isPassable(const CVector2D &loc/*tile space*/, HEntity entity) const
|
||||
{
|
||||
// TODO: Take into account the terrain type at this location
|
||||
return true;
|
||||
CMiniPatch *pTile = GetTile(loc.x, loc.y);
|
||||
CTextureEntry *pTexEntry = g_TexMan.FindTexture(pTile->Tex1);
|
||||
CTerrainPropertiesPtr pProperties = pTexEntry->GetProperties();
|
||||
|
||||
return pProperties->IsPassable(entity);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "maths/Vector3D.h"
|
||||
#include "graphics/SColor.h"
|
||||
|
||||
class HEntity;
|
||||
class CEntity;
|
||||
class CPatch;
|
||||
class CMiniPatch;
|
||||
@ -57,7 +58,7 @@ public:
|
||||
|
||||
bool isOnMap(const CVector2D& v) const;
|
||||
|
||||
bool isPassable(const CVector2D& tileSpaceLoc) const;
|
||||
bool isPassable(const CVector2D& tileSpaceLoc, HEntity entity) const;
|
||||
|
||||
void clampCoordToMap(int& index) const
|
||||
{
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "simulation/Entity.h"
|
||||
|
||||
#include "TerrainProperties.h"
|
||||
#include "TextureManager.h"
|
||||
#include "ps/Overlay.h"
|
||||
@ -13,6 +16,8 @@
|
||||
#include "ps/CLogger.h"
|
||||
#define LOG_CATEGORY "graphics"
|
||||
|
||||
using namespace std;
|
||||
|
||||
CTerrainProperties::CTerrainProperties(CTerrainPropertiesPtr parent):
|
||||
m_pParent(parent),
|
||||
m_BaseColor(0),
|
||||
@ -61,7 +66,7 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
if (child.getNodeName() == el_terrain)
|
||||
{
|
||||
CTerrainPropertiesPtr ret (new CTerrainProperties(parent));
|
||||
ret->LoadXML(child, &XeroFile);
|
||||
ret->LoadXML(child, &XeroFile, path);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
@ -77,21 +82,18 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
return CTerrainPropertiesPtr();
|
||||
}
|
||||
|
||||
void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile)
|
||||
void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile, const char *path)
|
||||
{
|
||||
#define ELMT(x) int elmt_##x = pFile->getElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->getAttributeID(#x)
|
||||
ELMT(doodad);
|
||||
ELMT(passable);
|
||||
ELMT(impassable);
|
||||
ELMT(event);
|
||||
// Terrain Attribs
|
||||
ATTR(mmap);
|
||||
ATTR(groups);
|
||||
ATTR(properties);
|
||||
// Passable Attribs
|
||||
ATTR(type);
|
||||
ATTR(speed);
|
||||
ATTR(effect);
|
||||
// Doodad Attribs
|
||||
ATTR(name);
|
||||
ATTR(max);
|
||||
@ -101,11 +103,8 @@ void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile)
|
||||
#undef ATTR
|
||||
|
||||
// stomp on "unused" warnings
|
||||
UNUSED2(attr_effect);
|
||||
UNUSED2(attr_name);
|
||||
UNUSED2(attr_type);
|
||||
UNUSED2(attr_on);
|
||||
UNUSED2(attr_speed);
|
||||
UNUSED2(attr_max);
|
||||
UNUSED2(elmt_event);
|
||||
UNUSED2(elmt_passable);
|
||||
@ -156,8 +155,76 @@ void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Parse information in child nodes (doodads, passable, events) and
|
||||
// store them somewhere
|
||||
XMBElementList children = node.getChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
|
||||
if (child.getNodeName() == elmt_passable)
|
||||
{
|
||||
ReadPassability(true, child, pFile, path);
|
||||
}
|
||||
else if (child.getNodeName() == elmt_impassable)
|
||||
{
|
||||
ReadPassability(false, child, pFile, path);
|
||||
}
|
||||
// TODO Parse information about doodads and events and store it
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrainProperties::ReadPassability(bool passable, XMBElement node, CXeromyces *pFile, const char *UNUSED(path))
|
||||
{
|
||||
#define ATTR(x) int attr_##x = pFile->getAttributeID(#x)
|
||||
// Passable Attribs
|
||||
ATTR(type);
|
||||
ATTR(speed);
|
||||
ATTR(effect);
|
||||
ATTR(prints);
|
||||
#undef ATTR
|
||||
|
||||
STerrainPassability pass(passable);
|
||||
bool hasType;
|
||||
bool hasSpeed;
|
||||
XMBAttributeList attribs = node.getAttributes();
|
||||
for (int i=0;i<attribs.Count;i++)
|
||||
{
|
||||
XMBAttribute attr = attribs.item(i);
|
||||
|
||||
if (attr.Name == attr_type)
|
||||
{
|
||||
// FIXME Should handle lists of types as well!
|
||||
pass.m_Type = attr.Value;
|
||||
hasType = true;
|
||||
}
|
||||
else if (attr.Name == attr_speed)
|
||||
{
|
||||
CStr val=attr.Value;
|
||||
CStr trimmedVal=val.Trim(PS_TRIM_BOTH);
|
||||
pass.m_SpeedFactor = trimmedVal.ToDouble();
|
||||
if (trimmedVal[trimmedVal.size()-1] == '%')
|
||||
{
|
||||
pass.m_SpeedFactor /= 100.0;
|
||||
}
|
||||
hasSpeed = true;
|
||||
}
|
||||
else if (attr.Name == attr_effect)
|
||||
{
|
||||
// TODO Parse and store list of effects
|
||||
}
|
||||
else if (attr.Name == attr_prints)
|
||||
{
|
||||
// TODO Parse and store footprint effect
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasType)
|
||||
{
|
||||
m_DefaultPassability = pass;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Passabilities.push_back(pass);
|
||||
}
|
||||
}
|
||||
|
||||
bool CTerrainProperties::HasBaseColor()
|
||||
@ -175,3 +242,24 @@ u32 CTerrainProperties::GetBaseColor()
|
||||
// White, full opacity.. but this value shouldn't ever be used
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
const STerrainPassability &CTerrainProperties::GetPassability(HEntity entity)
|
||||
{
|
||||
vector<STerrainPassability>::iterator it=m_Passabilities.begin();
|
||||
for (;it != m_Passabilities.end();++it)
|
||||
{
|
||||
if (entity->m_classes.IsMember(it->m_Type))
|
||||
return *it;
|
||||
}
|
||||
return m_DefaultPassability;
|
||||
}
|
||||
|
||||
bool CTerrainProperties::IsPassable(HEntity entity)
|
||||
{
|
||||
return GetPassability(entity).m_Passable;
|
||||
}
|
||||
|
||||
double CTerrainProperties::GetSpeedFactor(HEntity entity)
|
||||
{
|
||||
return GetPassability(entity).m_SpeedFactor;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef graphics_TerrainProperties_H
|
||||
#define graphics_TerrainProperties_H
|
||||
|
||||
#include "simulation/EntityHandles.h"
|
||||
#include "ps/CStr.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
@ -17,9 +18,22 @@ class CTerrainGroup;
|
||||
class XMBElement;
|
||||
class CXeromyces;
|
||||
class CTerrainProperties;
|
||||
class CEntity;
|
||||
|
||||
typedef boost::shared_ptr<CTerrainProperties> CTerrainPropertiesPtr;
|
||||
|
||||
struct STerrainPassability
|
||||
{
|
||||
explicit STerrainPassability(bool passable=true):
|
||||
m_Type(), m_Passable(passable), m_SpeedFactor(passable?1.0:0.0)
|
||||
{}
|
||||
|
||||
CStr m_Type;
|
||||
bool m_Passable;
|
||||
double m_SpeedFactor;
|
||||
// TODO Effects
|
||||
};
|
||||
|
||||
class CTerrainProperties
|
||||
{
|
||||
public:
|
||||
@ -36,10 +50,16 @@ private:
|
||||
u32 m_BaseColor;
|
||||
bool m_HasBaseColor;
|
||||
|
||||
STerrainPassability m_DefaultPassability;
|
||||
|
||||
// All terrain type groups we're a member of
|
||||
GroupVector m_Groups;
|
||||
|
||||
void LoadXML(XMBElement node, CXeromyces *pFile);
|
||||
// Passability definitions
|
||||
std::vector<STerrainPassability> m_Passabilities;
|
||||
|
||||
void ReadPassability(bool passable, XMBElement node, CXeromyces *pFile, const char *path);
|
||||
void LoadXML(XMBElement node, CXeromyces *pFile, const char *path);
|
||||
|
||||
public:
|
||||
CTerrainProperties(CTerrainPropertiesPtr parent);
|
||||
@ -64,6 +84,10 @@ public:
|
||||
// The color value is in BGRA format
|
||||
u32 GetBaseColor();
|
||||
|
||||
double GetSpeedFactor(HEntity entity);
|
||||
bool IsPassable(HEntity entity);
|
||||
const STerrainPassability &GetPassability(HEntity entity);
|
||||
|
||||
const GroupVector &GetGroups() const
|
||||
{ return m_Groups; }
|
||||
};
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <queue> // std::priority_queue
|
||||
|
||||
/*
|
||||
Cache for items of variable size and value/"cost".
|
||||
|
@ -189,10 +189,15 @@ LibError file_set_root_dir(const char* argv0, const char* rel_path)
|
||||
// (slight optimization, speeds up path lookup)
|
||||
if(!realpath(n_path, n_root_dir))
|
||||
return LibError_from_errno();
|
||||
|
||||
// .. append DIR_SEP to simplify code that uses n_root_dir
|
||||
// (note: already 0-terminated, since it's static)
|
||||
n_root_dir_len = strlen(n_root_dir)+1; // +1 for trailing DIR_SEP
|
||||
assert((n_root_dir_len+1) < sizeof(n_root_dir)); // Just checking
|
||||
n_root_dir[n_root_dir_len-1] = DIR_SEP;
|
||||
// You might think that n_root_dir is already 0-terminated, since it's
|
||||
// static - but that might not be true after calling file_reset_root_dir!
|
||||
n_root_dir[n_root_dir_len] = 0;
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ static LibError alc_init()
|
||||
// ignore
|
||||
}
|
||||
#else
|
||||
alc_dev = alcOpenDevice((ALCchar*)alc_dev_name);
|
||||
alc_dev = alcOpenDevice(alc_dev_name);
|
||||
#endif
|
||||
|
||||
if(alc_dev)
|
||||
@ -268,7 +268,12 @@ static LibError alc_init()
|
||||
if(err != ALC_NO_ERROR || !alc_dev || !alc_ctx)
|
||||
{
|
||||
debug_printf("alc_init failed. alc_dev=%p alc_ctx=%p alc_dev_name=%s err=%d\n", alc_dev, alc_ctx, alc_dev_name, err);
|
||||
// FIXME Hack to get around exclusive access to the sound device
|
||||
#if OS_UNIX
|
||||
ret = INFO::OK;
|
||||
#else
|
||||
ret = ERR::FAIL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// make note of which sound device is actually being used
|
||||
|
@ -106,7 +106,7 @@ For further details, see below.
|
||||
#ifndef SELF_TEST_H__
|
||||
#define SELF_TEST_H__
|
||||
|
||||
/*/*
|
||||
/*
|
||||
|
||||
// a self test is enabled if at the point of its definition
|
||||
// SELF_TEST_ENABLED evaluates to 1 (non-zero).
|
||||
@ -184,6 +184,10 @@ extern bool self_test_active;
|
||||
#define CXXTEST_HAVE_EH
|
||||
#define CXXTEST_HAVE_STD
|
||||
|
||||
// If HAVE_STD wasn't defined at the point the ValueTraits header was included
|
||||
// this header won't have been included and the default traits will be used for
|
||||
// all variables... So fix that now ;-)
|
||||
#include <cxxtest/StdValueTraits.h>
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#define TS_ASSERT_OK(expr) TS_ASSERT_EQUALS((expr), INFO::OK)
|
||||
|
@ -76,8 +76,8 @@ int dir_get_changed_file(char* fn)
|
||||
{
|
||||
if(initialized == -1)
|
||||
return ERR::FAIL; // NOWARN
|
||||
if(!initialized)
|
||||
WARN_RETURN(ERR::LOGIC);
|
||||
if(!initialized) // XXX Fix Atlas instead of supressing the warning
|
||||
return ERR::FAIL; //WARN_RETURN(ERR::LOGIC);
|
||||
|
||||
FAMEvent e;
|
||||
while(FAMPending(&fc) > 0)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#define PROFILE_RESOLVE_SYMBOL 0
|
||||
|
||||
// Hard-coded - yuck :P
|
||||
// These should only be used as fallbacks
|
||||
#if defined(TESTING)
|
||||
#define EXE_NAME "pyrogenesis_test"
|
||||
#elif defined(NDEBUG)
|
||||
@ -96,6 +97,7 @@ void udbg_launch_debugger()
|
||||
else if (ret > 0)
|
||||
{
|
||||
// Parent (original) fork:
|
||||
debug_printf("Sleeping until debugger attaches.\nPlease wait.\n");
|
||||
sleep(DEBUGGER_WAIT);
|
||||
}
|
||||
else // fork error, ret == -1
|
||||
@ -141,7 +143,7 @@ LibError debug_dump_stack(wchar_t* buf, size_t max_chars, uint skip, void* UNUSE
|
||||
char file[DBG_FILE_LEN];
|
||||
char symbol[DBG_SYMBOL_LEN];
|
||||
int line;
|
||||
uint len;
|
||||
int len;
|
||||
|
||||
if (debug_resolve_symbol(bt[i], symbol, file, &line) == 0)
|
||||
len = swprintf(bufpos, MAX_OUT_CHARS, L"(0x%08x) %hs:%d %hs\n", bt[i], file, line, symbol);
|
||||
@ -168,7 +170,7 @@ static int slurp_symtab(symbol_file_context *ctx)
|
||||
bfd *abfd=ctx->abfd;
|
||||
asymbol ***syms=&ctx->syms;
|
||||
long symcount;
|
||||
unsigned int size=0;
|
||||
int size=0;
|
||||
|
||||
if ((bfd_get_file_flags (abfd) & HAS_SYMS) == 0)
|
||||
{
|
||||
@ -188,9 +190,9 @@ static int slurp_symtab(symbol_file_context *ctx)
|
||||
symcount = bfd_canonicalize_symtab(abfd, *syms);
|
||||
|
||||
if (symcount == 0)
|
||||
symcount = bfd_read_minisymbols (abfd, FALSE, (void **)syms, &size);
|
||||
symcount = bfd_read_minisymbols (abfd, FALSE, (void **)syms, (uint *)&size);
|
||||
if (symcount == 0)
|
||||
symcount = bfd_read_minisymbols (abfd, TRUE /* dynamic */, (void **)syms, &size);
|
||||
symcount = bfd_read_minisymbols (abfd, TRUE /* dynamic */, (void **)syms, (uint *)&size);
|
||||
|
||||
if (symcount < 0)
|
||||
{
|
||||
@ -243,7 +245,17 @@ static int read_symbols(const char *file_name, symbol_file_context *ctx)
|
||||
|
||||
void udbg_init(void)
|
||||
{
|
||||
if (read_symbols(EXE_NAME, &ps_dbg_context)==0)
|
||||
char n_path[PATH_MAX];
|
||||
char *exename=n_path;
|
||||
if (sys_get_executable_name(n_path, sizeof(n_path)) != INFO::OK)
|
||||
{
|
||||
debug_printf("sys_get_executable_name didn't work, using hard-coded guess %s.\n", EXE_NAME);
|
||||
exename=EXE_NAME;
|
||||
}
|
||||
|
||||
debug_printf("udbg_init: loading symbols from %s.\n", exename);
|
||||
|
||||
if (read_symbols(exename, &ps_dbg_context)==0)
|
||||
udbg_initialized=true;
|
||||
|
||||
#if PROFILE_RESOLVE_SYMBOL
|
||||
|
@ -26,9 +26,18 @@
|
||||
#include "lib/lib.h"
|
||||
#include "lib/debug.h"
|
||||
#include "lib/sysdep/gfx.h"
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_syswm.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
static Display *SDL_Display;
|
||||
static Window SDL_Window;
|
||||
static void (*Lock_Display)(void);
|
||||
static void (*Unlock_Display)(void);
|
||||
static wchar_t *selection_data=NULL;
|
||||
static size_t selection_size=0;
|
||||
|
||||
// useful for choosing a video mode. not called by detect().
|
||||
// if we fail, outputs are unchanged (assumed initialized to defaults)
|
||||
LibError gfx_get_video_mode(int* xres, int* yres, int* bpp, int* freq)
|
||||
@ -193,19 +202,132 @@ LibError sys_clipboard_free(wchar_t *clip_buf)
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Setting the Selection (i.e. "copy")
|
||||
* Would require overriding the SDL X event handler to receive other apps'
|
||||
requests for the selection buffer
|
||||
* Step-by-step:
|
||||
* Store the selection text in a local buffer
|
||||
* Tell the X server that we want to own the selection
|
||||
* Listen for Selection events and respond to them as appropriate
|
||||
/**
|
||||
* An SDL Event filter that intercepts other applications' requests for the
|
||||
* X selection buffer.
|
||||
*
|
||||
* @see x11_clipboard_init
|
||||
* @see sys_clipboard_set
|
||||
*/
|
||||
LibError sys_clipboard_set(const wchar_t *clip_str)
|
||||
int clipboard_filter(const SDL_Event *event)
|
||||
{
|
||||
// Not Implemented, see comment before clipboard_get, above
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
/* Pass on all non-window manager specific events immediately */
|
||||
/* And do nothing if we don't actually have a clip-out to send out */
|
||||
if (event->type != SDL_SYSWMEVENT || !selection_data)
|
||||
return 1;
|
||||
|
||||
/* Handle window-manager specific clipboard events */
|
||||
switch (event->syswm.msg->event.xevent.type) {
|
||||
/* Copy the selection from our buffer to the requested property, and
|
||||
convert to the requested target format */
|
||||
case SelectionRequest: {
|
||||
XSelectionRequestEvent *req;
|
||||
XEvent sevent;
|
||||
|
||||
req = &event->syswm.msg->event.xevent.xselectionrequest;
|
||||
sevent.xselection.type = SelectionNotify;
|
||||
sevent.xselection.display = req->display;
|
||||
sevent.xselection.selection = req->selection;
|
||||
sevent.xselection.target = req->target;
|
||||
sevent.xselection.property = None;
|
||||
sevent.xselection.requestor = req->requestor;
|
||||
sevent.xselection.time = req->time;
|
||||
// Simply strip all non-Latin1 characters and replace with '?'
|
||||
// We should support XA_UTF8
|
||||
if (req->target == XA_STRING)
|
||||
{
|
||||
size_t size = wcslen(selection_data);
|
||||
u8 *buf = (u8 *)alloca(size);
|
||||
|
||||
for (size_t i=0;i<size;i++)
|
||||
{
|
||||
buf[i] = selection_data[i]<0x100?selection_data[i]:'?';
|
||||
}
|
||||
|
||||
XChangeProperty(SDL_Display, req->requestor, req->property,
|
||||
sevent.xselection.target, 8, PropModeReplace,
|
||||
buf, size);
|
||||
sevent.xselection.property = req->property;
|
||||
}
|
||||
// TODO Add more target formats
|
||||
XSendEvent(SDL_Display,req->requestor,False,0,&sevent);
|
||||
XSync(SDL_Display, False);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization for X clipboard handling, called on-demand by
|
||||
* sys_clipboard_set.
|
||||
*/
|
||||
LibError x11_clipboard_init()
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
if ( SDL_GetWMInfo(&info) )
|
||||
{
|
||||
/* Save the information for later use */
|
||||
if ( info.subsystem == SDL_SYSWM_X11 )
|
||||
{
|
||||
SDL_Display = info.info.x11.display;
|
||||
SDL_Window = info.info.x11.window;
|
||||
Lock_Display = info.info.x11.lock_func;
|
||||
Unlock_Display = info.info.x11.unlock_func;
|
||||
|
||||
/* Enable the special window hook events */
|
||||
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
||||
SDL_SetEventFilter(clipboard_filter);
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERR::FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Selection (i.e. "copy")
|
||||
*
|
||||
* Step-by-step (X11)
|
||||
* <ul>
|
||||
* <li>Store the selection text in a local buffer
|
||||
* <li>Tell the X server that we want to own the selection
|
||||
* <li>Listen for Selection events and respond to them as appropriate
|
||||
* </ul>
|
||||
*/
|
||||
LibError sys_clipboard_set(const wchar_t *str)
|
||||
{
|
||||
ONCE(x11_clipboard_init());
|
||||
|
||||
debug_printf("sys_clipboard_set: %ls\n", str);
|
||||
|
||||
if (selection_data)
|
||||
{
|
||||
free(selection_data);
|
||||
selection_data = NULL;
|
||||
}
|
||||
|
||||
selection_size = (wcslen(str)+1)*sizeof(wchar_t);
|
||||
selection_data = (wchar_t *)malloc(selection_size);
|
||||
wcscpy(selection_data, str);
|
||||
|
||||
Lock_Display();
|
||||
// Like for the clipboard_get code above, we rather use CLIPBOARD than
|
||||
// PRIMARY - more windows'y behaviour there.
|
||||
Atom clipboard_atom = XInternAtom(SDL_Display, "CLIPBOARD", False);
|
||||
XSetSelectionOwner(SDL_Display, clipboard_atom, SDL_Window, CurrentTime);
|
||||
XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
|
||||
Unlock_Display();
|
||||
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
#endif // #ifdef HAVE_X
|
||||
|
@ -222,7 +222,8 @@ public:
|
||||
{
|
||||
uint x = rand(1, 3);
|
||||
// paranoia: don't use array (x might not be 1 or 2 - checked below)
|
||||
if(x == 1) ones++; if(x == 2) twos++;
|
||||
if(x == 1) ones++;
|
||||
if(x == 2) twos++;
|
||||
}
|
||||
TS_ASSERT_EQUALS(ones+twos, 100);
|
||||
TS_ASSERT(ones > 10 && twos > 10);
|
||||
|
@ -188,8 +188,10 @@ class TestMultithread : public CxxTest::TestSuite
|
||||
public:
|
||||
TestMultithread()
|
||||
: is_complete(false), num_active_threads(0),
|
||||
list(), hash(),
|
||||
mutex() {}
|
||||
list(), hash()
|
||||
{
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
}
|
||||
|
||||
void disabled_due_to_failure_on_p4_test_multithread()
|
||||
{
|
||||
|
@ -3,15 +3,36 @@
|
||||
|
||||
#include "lib/path_util.h"
|
||||
|
||||
class TestPathUtil : public CxxTest::TestSuite
|
||||
{
|
||||
void TEST_APPEND(const char* path1, const char* path2, uint flags, const char* correct_result)
|
||||
{
|
||||
char dst[PATH_MAX] = {0};
|
||||
TS_ASSERT_OK(path_append(dst, path1, path2, flags));
|
||||
TS_ASSERT_STR_EQUALS(dst, correct_result);
|
||||
// Macros, not functions, to get proper line number reports when tests fail
|
||||
#define TEST_APPEND(path1, path2, flags, correct_result) \
|
||||
{ \
|
||||
char dst[PATH_MAX] = {0}; \
|
||||
TS_ASSERT_OK(path_append(dst, path1, path2, flags)); \
|
||||
TS_ASSERT_STR_EQUALS(dst, correct_result); \
|
||||
}
|
||||
|
||||
#define TEST_NAME_ONLY(path, correct_result) \
|
||||
{ \
|
||||
const char* result = path_name_only(path); \
|
||||
TS_ASSERT_STR_EQUALS(result, correct_result); \
|
||||
}
|
||||
|
||||
#define TEST_LAST_COMPONENT(path, correct_result) \
|
||||
{ \
|
||||
const char* result = path_last_component(path); \
|
||||
TS_ASSERT_STR_EQUALS(result, correct_result); \
|
||||
}
|
||||
|
||||
#define TEST_STRIP_FN(path_readonly, correct_result) \
|
||||
{ \
|
||||
char path[PATH_MAX]; \
|
||||
path_copy(path, path_readonly); \
|
||||
path_strip_fn(path); \
|
||||
TS_ASSERT_STR_EQUALS(path, correct_result); \
|
||||
}
|
||||
|
||||
class TestPathUtil : public CxxTest::TestSuite
|
||||
{
|
||||
// if correct_ret is ERR::FAIL, ignore correct_result.
|
||||
void TEST_REPLACE(const char* src, const char* remove, const char* replace,
|
||||
LibError correct_ret, const char* correct_result)
|
||||
@ -22,26 +43,6 @@ class TestPathUtil : public CxxTest::TestSuite
|
||||
TS_ASSERT_STR_EQUALS(dst, correct_result);
|
||||
}
|
||||
|
||||
void TEST_NAME_ONLY(const char* path, const char* correct_result)
|
||||
{
|
||||
const char* result = path_name_only(path);
|
||||
TS_ASSERT_STR_EQUALS(result, correct_result);
|
||||
}
|
||||
|
||||
void TEST_LAST_COMPONENT(const char* path, const char* correct_result)
|
||||
{
|
||||
const char* result = path_last_component(path);
|
||||
TS_ASSERT_STR_EQUALS(result, correct_result);
|
||||
}
|
||||
|
||||
void TEST_STRIP_FN(const char* path_readonly, const char* correct_result)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
path_copy(path, path_readonly);
|
||||
path_strip_fn(path);
|
||||
TS_ASSERT_STR_EQUALS(path, correct_result);
|
||||
}
|
||||
|
||||
void TEST_PATH_EXT(const char* path, const char* correct_result)
|
||||
{
|
||||
const char* result = path_extension(path);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define LOG_CAT_NET "net"
|
||||
|
||||
// NEVER modify the deserializer map outside the ONCE-block in DeserializeMessage
|
||||
// Please don't modify the deserializer map outside the ONCE-block in DeserializeMessage
|
||||
typedef std::map <ENetMessageType, NetMessageDeserializer> MessageDeserializerMap;
|
||||
MessageDeserializerMap g_DeserializerMap;
|
||||
|
||||
|
@ -751,8 +751,8 @@ void CConsole::SendChatMessage(const wchar_t *szMessage)
|
||||
g_NetClient->Push(msg);
|
||||
else
|
||||
{
|
||||
msg->m_Sender=g_NetServer->GetServerPlayerName();
|
||||
ReceivedChatMessage(msg->m_Sender.c_str(), msg->m_Message.c_str());
|
||||
msg->m_Sender=0;
|
||||
ReceivedChatMessage(g_NetServer->GetServerPlayerName(), msg->m_Message.c_str());
|
||||
g_NetServer->Broadcast(msg);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,11 @@
|
||||
#include "simulation/Simulation.h"
|
||||
#include "graphics/GameView.h"
|
||||
|
||||
#include "network/Client.h"
|
||||
|
||||
class CNetServer;
|
||||
extern CNetServer *g_NetServer;
|
||||
|
||||
extern CConsole* g_Console;
|
||||
extern bool g_GameRestarted;
|
||||
|
||||
@ -118,8 +123,12 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs)
|
||||
{
|
||||
// JW: this loop is taken from ScEd and fixes lack of player color.
|
||||
// TODO: determine proper number of players.
|
||||
// SB: Only do this for non-network games
|
||||
if (!g_NetClient && !g_NetServer)
|
||||
{
|
||||
for (int i=1; i<8; ++i)
|
||||
pAttribs->GetSlot(i)->AssignLocal();
|
||||
}
|
||||
|
||||
pAttribs->FinalizeSlots();
|
||||
m_NumPlayers=pAttribs->GetSlotCount();
|
||||
@ -130,6 +139,13 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs)
|
||||
for (uint i=0;i <= m_NumPlayers;i++)
|
||||
m_Players[i]=pAttribs->GetPlayer(i);
|
||||
|
||||
if (g_NetClient)
|
||||
{
|
||||
// TODO
|
||||
//m_pLocalPlayer=g_NetClient->GetLocalPlayer();
|
||||
debug_assert(m_pLocalPlayer && "Darn it! We weren't assigned to a slot!");
|
||||
}
|
||||
else
|
||||
m_pLocalPlayer=m_Players[1];
|
||||
|
||||
RegisterInit(pAttribs);
|
||||
|
@ -150,7 +150,7 @@ namespace PlayerSlotArray_JS
|
||||
return JS_FALSE;
|
||||
uint index=ToPrimitive<uint>(id);
|
||||
|
||||
if (index > pInstance->m_NumSlots)
|
||||
if (index >= pInstance->m_NumSlots)
|
||||
return JS_FALSE;
|
||||
|
||||
*vp=OBJECT_TO_JSVAL(pInstance->m_PlayerSlots[index]->GetScript());
|
||||
|
@ -9,8 +9,28 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
static void* const ATLAS_SO_UNAVAILABLE = (void*)-1;
|
||||
static void* atlas_so_handle;
|
||||
static void* atlas_so_handle = NULL;
|
||||
|
||||
// Calculate the correct AtlasUI DLL
|
||||
// TODO Use path_util instead, get the actual path to the ps_dbg exe and append
|
||||
// the library name.
|
||||
|
||||
// note: on Linux, lib is prepended to the SO file name and we need to add ./
|
||||
// to make dlopen look in the current working directory
|
||||
#if OS_UNIX
|
||||
# define PREFIX "./lib"
|
||||
#else
|
||||
# define PREFIX ""
|
||||
#endif
|
||||
// since this SO exports a C++ interface, it is critical that
|
||||
// compiler options are the same between app and SO; therefore,
|
||||
// we need to go with the debug version in debug builds.
|
||||
// note: on Windows, the extension is replaced with .dll by dlopen.
|
||||
#ifndef NDEBUG
|
||||
static const char* so_name = PREFIX "AtlasUI_dbg.so";
|
||||
#else
|
||||
static const char* so_name = PREFIX "AtlasUI.so";
|
||||
#endif
|
||||
|
||||
// free reference to Atlas UI SO (avoids resource leak report)
|
||||
void ATLAS_Shutdown()
|
||||
@ -31,15 +51,6 @@ static bool ATLAS_IsAvailable()
|
||||
// postcondition: atlas_so_handle valid or == ATLAS_SO_UNAVAILABLE.
|
||||
if(atlas_so_handle == 0)
|
||||
{
|
||||
// since this SO exports a C++ interface, it is critical that
|
||||
// compiler options are the same between app and SO; therefore,
|
||||
// we need to go with the debug version in debug builds.
|
||||
// note: on Windows, the extension is replaced with .dll by dlopen.
|
||||
#ifndef NDEBUG
|
||||
const char* so_name = "AtlasUI_dbg.so";
|
||||
#else
|
||||
const char* so_name = "AtlasUI.so";
|
||||
#endif
|
||||
// we don't really care when relocations take place, but one of
|
||||
// {RTLD_NOW, RTLD_LAZY} must be passed. go with the former because
|
||||
// it is safer and matches the Windows load behavior.
|
||||
|
@ -1130,7 +1130,7 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
// SDL_BUTTON_* values; these are verified at compile time.
|
||||
cassert(SDL_BUTTON_LEFT == 1 && SDL_BUTTON_MIDDLE == 2 && SDL_BUTTON_RIGHT == 3 && \
|
||||
SDL_BUTTON_WHEELUP == 4 && SDL_BUTTON_WHEELDOWN == 5);
|
||||
const uint SDL_BUTTON_INDEX_COUNT = 6;
|
||||
const int SDL_BUTTON_INDEX_COUNT = 6;
|
||||
static double lastclicktime[SDL_BUTTON_INDEX_COUNT];
|
||||
static HEntity lastclickobject[SDL_BUTTON_INDEX_COUNT];
|
||||
static u8 clicks[SDL_BUTTON_INDEX_COUNT];
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "CStr.h"
|
||||
#include "Singleton.h"
|
||||
#include "simulation/EntityHandles.h"
|
||||
#include "ps/Vector2D.h"
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
TS_ASSERT_SAME_DATA(str_utf8.data(), chr_utf8, sizeof(chr_utf8));
|
||||
|
||||
CStrW str_utf16b = str_utf8.FromUTF8();
|
||||
TS_ASSERT_EQUALS(str_utf16b, str_utf16);
|
||||
TS_ASSERT_WSTR_EQUALS(str_utf16b, str_utf16);
|
||||
}
|
||||
|
||||
void test_invalid_utf8()
|
||||
|
@ -48,12 +48,9 @@ namespace std {
|
||||
|
||||
static const char_type* find(const char_type* s, size_t n, const char_type& a)
|
||||
{
|
||||
size_t i;
|
||||
for (i=0;i<n;i++)
|
||||
{
|
||||
if (s[i] == a) return s+i;
|
||||
}
|
||||
return NULL;
|
||||
const char_type *end = s+n;
|
||||
const char_type *res = std::find(s, end, a);
|
||||
return (res != end)?res:NULL;
|
||||
}
|
||||
|
||||
static char_type* move(char_type* s1, const char_type* s2, size_t n)
|
||||
|
@ -4,8 +4,12 @@
|
||||
|
||||
/* For AStarGoalLowLevel isPassable/cost */
|
||||
#include "Collision.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include "ps/Game.h"
|
||||
#include "ps/World.h"
|
||||
#include "graphics/TextureEntry.h"
|
||||
#include "graphics/TerrainProperties.h"
|
||||
#include "graphics/Patch.h"
|
||||
#include "graphics/Terrain.h"
|
||||
|
||||
@ -63,7 +67,7 @@ CAStarEngine::~CAStarEngine()
|
||||
|
||||
|
||||
bool CAStarEngine::findPath(
|
||||
const CVector2D &src, const CVector2D &dest, CPlayer* player, float radius )
|
||||
const CVector2D &src, const CVector2D &dest, HEntity entity, float radius )
|
||||
{
|
||||
mSolved = false;
|
||||
int iterations = 0;
|
||||
@ -103,7 +107,7 @@ bool CAStarEngine::findPath(
|
||||
/* Get neighbors of the best node */
|
||||
std::vector<CVector2D> neighbors;
|
||||
PROFILE_START("get neighbors");
|
||||
neighbors = mGoal->getNeighbors(best->coord, player);
|
||||
neighbors = mGoal->getNeighbors(best->coord, entity);
|
||||
PROFILE_END("get neighbors");
|
||||
|
||||
/* Update the neighbors of the best node */
|
||||
@ -356,7 +360,7 @@ float AStarGoalLowLevel::getTileCost( const CVector2D& loc1, const CVector2D& lo
|
||||
return (loc2-loc1).length() - radius;
|
||||
}
|
||||
|
||||
bool AStarGoalLowLevel::isPassable( const CVector2D &loc, CPlayer* player )
|
||||
bool AStarGoalLowLevel::isPassable( const CVector2D &loc, HEntity entity )
|
||||
{
|
||||
CTerrain* pTerrain = g_Game->GetWorld()->GetTerrain();
|
||||
int size = pTerrain->GetTilesPerSide();
|
||||
@ -366,12 +370,12 @@ bool AStarGoalLowLevel::isPassable( const CVector2D &loc, CPlayer* player )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( pTerrain->isPassable(loc) )
|
||||
if ( pTerrain->isPassable(loc, entity) )
|
||||
{
|
||||
// If no entity blocking, return true
|
||||
CVector2D wloc = TilespaceToWorldspace(loc);
|
||||
CBoundingBox bounds(wloc.x, wloc.y, 0, CELL_SIZE, CELL_SIZE, 3);
|
||||
if ( getCollisionObject(&bounds, player) == NULL )
|
||||
if ( getCollisionObject(&bounds, entity->GetPlayer()) == NULL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -389,7 +393,7 @@ CVector2D AStarGoalLowLevel::getTile( const CVector2D &loc )
|
||||
return WorldspaceToTilespace(loc);
|
||||
}
|
||||
|
||||
std::vector<CVector2D> AStarGoalLowLevel::getNeighbors( const CVector2D &loc, CPlayer* player )
|
||||
std::vector<CVector2D> AStarGoalLowLevel::getNeighbors( const CVector2D &loc, HEntity entity)
|
||||
{
|
||||
std::vector<CVector2D> vec;
|
||||
|
||||
@ -401,7 +405,7 @@ std::vector<CVector2D> AStarGoalLowLevel::getNeighbors( const CVector2D &loc, CP
|
||||
{
|
||||
CVector2D c = loc;
|
||||
c.x += xdiff; c.y += ydiff;
|
||||
if ( isPassable(c, player) )
|
||||
if ( isPassable(c, entity) )
|
||||
{
|
||||
vec.push_back(c);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
void setGoal(AStarGoalBase* goal) { mGoal = goal; }
|
||||
|
||||
bool findPath( const CVector2D& src, const CVector2D& dest, CPlayer* player=0, float radius=0.0f );
|
||||
bool findPath( const CVector2D& src, const CVector2D& dest, HEntity entity, float radius=0.0f );
|
||||
std::vector<CVector2D> getLastPath();
|
||||
|
||||
// The maximum number of nodes that will be expanded before failure is declared
|
||||
@ -132,8 +132,8 @@ public:
|
||||
virtual float distanceToGoal( const CVector2D& ) = 0;
|
||||
virtual bool atGoal( const CVector2D& ) = 0;
|
||||
virtual float getTileCost( const CVector2D&, const CVector2D& ) = 0;
|
||||
virtual bool isPassable( const CVector2D&, CPlayer* player=0 ) = 0;
|
||||
virtual std::vector<CVector2D> getNeighbors( const CVector2D&, CPlayer* player=0 ) = 0;
|
||||
virtual bool isPassable( const CVector2D&, HEntity entity) = 0;
|
||||
virtual std::vector<CVector2D> getNeighbors( const CVector2D&, HEntity entity) = 0;
|
||||
virtual CVector2D getCoord( const CVector2D& ) = 0;
|
||||
virtual CVector2D getTile( const CVector2D& ) = 0;
|
||||
virtual float getRadius() = 0;
|
||||
@ -148,8 +148,8 @@ public:
|
||||
float distanceToGoal( const CVector2D& loc );
|
||||
bool atGoal( const CVector2D& loc );
|
||||
float getTileCost( const CVector2D& loc1, const CVector2D& loc2 );
|
||||
bool isPassable( const CVector2D& loc, CPlayer* player=0 );
|
||||
std::vector<CVector2D> getNeighbors( const CVector2D& loc, CPlayer* player=0 );
|
||||
bool isPassable( const CVector2D& loc, HEntity entity);
|
||||
std::vector<CVector2D> getNeighbors( const CVector2D& loc, HEntity entity);
|
||||
CVector2D getCoord( const CVector2D& loc);
|
||||
CVector2D getTile( const CVector2D& loc);
|
||||
float getRadius();
|
||||
|
@ -36,7 +36,7 @@ void CPathfindEngine::requestLowLevelPath( HEntity entity, const CVector2D& dest
|
||||
|
||||
CVector2D source( entity->m_position.X, entity->m_position.Z );
|
||||
|
||||
if ( mLowPathfinder.findPath(source, destination, entity->GetPlayer(), radius) )
|
||||
if ( mLowPathfinder.findPath(source, destination, entity, radius) )
|
||||
{
|
||||
std::vector<CVector2D> path = mLowPathfinder.getLastPath();
|
||||
if( path.size() > 0 )
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef SCRIPTOBJECT_INCLUDED
|
||||
#define SCRIPTOBJECT_INCLUDED
|
||||
|
||||
#include "scripting/SpiderMonkey.h"
|
||||
|
||||
class CStrW;
|
||||
class CScriptEvent;
|
||||
|
||||
|
@ -37,14 +37,9 @@ Example SoundGroup.xml
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef SOUNDGROUP_H_
|
||||
#define SOUNDGROUP_H_
|
||||
|
||||
|
||||
#include "lib/res/handle.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "lib/res/sound/snd_mgr.h"
|
||||
@ -52,11 +47,16 @@ Example SoundGroup.xml
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
enum eSndGrpFlags{ eRandOrder = 0x01, eRandGain = 0x02, eRandPitch = 0x04, eLoop = 0x08 };
|
||||
enum eSndGrpFlags
|
||||
{
|
||||
eRandOrder = 0x01,
|
||||
eRandGain = 0x02,
|
||||
eRandPitch = 0x04,
|
||||
eLoop = 0x08
|
||||
};
|
||||
|
||||
class CSoundGroup
|
||||
{
|
||||
|
||||
size_t m_index; // index of the next sound to play
|
||||
|
||||
vector<Handle> snd_group; // we store the handles so we can load now and play later
|
||||
@ -102,9 +102,6 @@ public:
|
||||
// Test flag, returns true if flag is set.
|
||||
inline bool TestFlag(int flag) { return (m_Flags & flag) == flag;}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //#ifndef SOUNDGROUP_H_
|
||||
|
@ -1,3 +1,5 @@
|
||||
#if OS_WIN
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
@ -7,10 +9,17 @@
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#if OS_WIN
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
|
||||
#else
|
||||
int main() {
|
||||
#endif
|
||||
Atlas_StartWindow(L"ActorEditor");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#if OS_WIN
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
@ -7,10 +9,17 @@
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#if OS_WIN
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
|
||||
#else
|
||||
int main() {
|
||||
#endif
|
||||
Atlas_StartWindow(L"ArchiveViewer");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#if OS_WIN
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
@ -7,10 +9,17 @@
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#if OS_WIN
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
|
||||
#else
|
||||
int main() {
|
||||
#endif
|
||||
Atlas_StartWindow(L"ColourTester");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#if OS_WIN
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
@ -7,10 +9,17 @@
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#if OS_WIN
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
|
||||
#else
|
||||
int main() {
|
||||
#endif
|
||||
Atlas_StartWindow(L"FileConverter");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#if OS_WIN
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
@ -7,10 +9,17 @@
|
||||
# endif
|
||||
|
||||
# define ATLASDLLIMPEXP extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
||||
#include "AtlasUI/Misc/DLLInterface.h"
|
||||
|
||||
#if OS_WIN
|
||||
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
|
||||
#else
|
||||
int main() {
|
||||
#endif
|
||||
Atlas_StartWindow(L"$$WINDOW_NAME$$");
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define ATLASOBJECT_H__
|
||||
|
||||
#include <wchar.h> // for wchar_t
|
||||
#include <wx/string.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Mostly-private bits:
|
||||
@ -80,14 +81,17 @@ public:
|
||||
const AtIter operator [] (const char* key) const;
|
||||
|
||||
// Return the AtObj currently pointed to by this iterator
|
||||
operator const AtObj () const;
|
||||
//operator const AtObj () const;
|
||||
const AtObj operator *() const;
|
||||
|
||||
// Return the string value of the AtObj currently pointed to by this iterator
|
||||
operator const wchar_t* () const;
|
||||
//operator const wxChar* () const { return (const wchar_t*)*this; }
|
||||
|
||||
#ifdef __WXWINDOWS__
|
||||
// Wrapper function around 'operator wchar_t*', for convenience in wx programs
|
||||
operator const wxString () const { return (const wchar_t*)*this; }
|
||||
//operator wxString () const { return (const wchar_t*)*this; }
|
||||
//wxString towxString() const { return (const wchar_t*)*this; }
|
||||
#endif
|
||||
|
||||
// Private implementation. (But not 'private:', because it's a waste of time
|
||||
|
@ -41,7 +41,8 @@ AtIter::operator const wchar_t* () const
|
||||
return L"";
|
||||
}
|
||||
|
||||
AtIter::operator const AtObj () const
|
||||
//AtIter::operator const AtObj () const
|
||||
const AtObj AtIter::operator * () const
|
||||
{
|
||||
if (p)
|
||||
{
|
||||
@ -68,12 +69,12 @@ AtIter& AtIter::operator ++ ()
|
||||
|
||||
bool AtIter::defined() const
|
||||
{
|
||||
return (p != NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
bool AtIter::hasContent() const
|
||||
{
|
||||
if (p == NULL)
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
if (! p->iter->second)
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "wx/file.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(ActorEditor, AtlasWindow)
|
||||
EVT_MENU(ID_CreateEntity, OnCreateEntity)
|
||||
EVT_MENU(ID_CreateEntity, ActorEditor::OnCreateEntity)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@ -86,12 +86,12 @@ ActorEditor::ActorEditor(wxWindow* parent)
|
||||
|
||||
void ActorEditor::ThawData(AtObj& in)
|
||||
{
|
||||
AtObj actor (in["actor"]);
|
||||
AtObj actor (*in["actor"]);
|
||||
m_ActorEditorListCtrl->ThawData(actor);
|
||||
|
||||
m_CastShadows->SetValue(actor["castshadow"].defined());
|
||||
m_Float->SetValue(actor["float"].defined());
|
||||
m_Material->SetValue(actor["material"]);
|
||||
m_Material->SetValue((wxString)actor["material"]);
|
||||
}
|
||||
|
||||
AtObj ActorEditor::FreezeData()
|
||||
@ -112,7 +112,6 @@ AtObj ActorEditor::FreezeData()
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
static AtObj ConvertToLatestFormat(AtObj in)
|
||||
{
|
||||
if (! in.defined())
|
||||
@ -297,12 +296,12 @@ void ActorEditor::ImportData(AtObj& in)
|
||||
|
||||
// Copy the data into the appropriate UI controls:
|
||||
|
||||
AtObj actor (data["actor"]);
|
||||
AtObj actor (*data["actor"]);
|
||||
m_ActorEditorListCtrl->ImportData(actor);
|
||||
|
||||
m_CastShadows->SetValue(actor["castshadow"].defined());
|
||||
m_Float->SetValue(actor["float"].defined());
|
||||
m_Material->SetValue(actor["material"]);
|
||||
m_Material->SetValue((wxString)actor["material"]);
|
||||
}
|
||||
|
||||
AtObj ActorEditor::ExportData()
|
||||
@ -398,7 +397,7 @@ void ActorEditor::OnCreateEntity(wxCommandEvent& WXUNUSED(event))
|
||||
_T("\t<Actor>") + actorFilename.GetFullPath(wxPATH_UNIX) + _T("</Actor>\r\n")
|
||||
_T("</Entity>\r\n");
|
||||
|
||||
wxFile file (outputEntityFilename.fn_str(), wxFile::write);
|
||||
wxFile file (outputEntityFilename.c_str(), wxFile::write);
|
||||
if (! file.IsOpened())
|
||||
{
|
||||
wxLogError(_("Failed to open file"));
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "ActorViewer.h"
|
||||
|
||||
#include "wx/treectrl.h"
|
||||
#include "wx/regex.h"
|
||||
|
||||
#include "General/Datafile.h"
|
||||
|
||||
@ -190,7 +191,9 @@ ActorViewer::ActorViewer(wxWindow* parent)
|
||||
|
||||
splitter->SplitVertically(sidePanel, canvas);
|
||||
|
||||
#if OS_WIN
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
#endif
|
||||
POST_MESSAGE(SetContext, (canvas->GetContext()));
|
||||
|
||||
POST_MESSAGE(Init, (false));
|
||||
@ -255,7 +258,7 @@ ActorViewer::ActorViewer(wxWindow* parent)
|
||||
|
||||
AtObj animationsList (Datafile::ReadList("animations"));
|
||||
for (AtIter it = animationsList["item"]; it.defined(); ++it)
|
||||
animations.Add(it);
|
||||
animations.Add((const wchar_t *)it);
|
||||
|
||||
m_AnimationBox = new wxComboBox(sidePanel, ID_Animations, _T("Idle"), wxDefaultPosition, wxDefaultSize, animations);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "Misc/Version.h"
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include "DatafileIO/BAR/BAR.h"
|
||||
@ -15,7 +16,9 @@ using namespace DatafileIO;
|
||||
#include "wx/confbase.h"
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/tooltip.h"
|
||||
#ifdef _WIN32
|
||||
#include "wx/msw/registry.h"
|
||||
#endif
|
||||
#include "wx/progdlg.h"
|
||||
#include "wx/regex.h"
|
||||
|
||||
@ -102,7 +105,7 @@ END_EVENT_TABLE()
|
||||
ArchiveViewer::ArchiveViewer(wxWindow* parent)
|
||||
: wxFrame(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, 371))
|
||||
, m_FileHistory(_T("Archive Viewer"))
|
||||
, m_WindowTitle(wxString::Format(_("%s - Archive Viewer"), g_ProgramNameVersion))
|
||||
, m_WindowTitle(wxString::Format(_("%s - Archive Viewer"), g_ProgramNameVersion.c_str()))
|
||||
, m_BARStream(NULL), m_BARReader(NULL), m_PreviewEnabled(false)
|
||||
{
|
||||
SetIcon(wxIcon(_T("ICON_ArchiveViewer")));
|
||||
@ -190,7 +193,7 @@ ArchiveViewer::ArchiveViewer(wxWindow* parent)
|
||||
|
||||
void ArchiveViewer::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxMessageBox(wxString::Format(_("%s - created by Philip Taylor (philip@wildfiregames.com / philip@zaynar.demon.co.uk)"), g_ProgramNameVersion),
|
||||
wxMessageBox(wxString::Format(_("%s - created by Philip Taylor (philip@wildfiregames.com / philip@zaynar.demon.co.uk)"), g_ProgramNameVersion.c_str()),
|
||||
_("About"), wxOK|wxCENTRE|wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
@ -303,7 +306,7 @@ void ArchiveViewer::UpdateFileList()
|
||||
|
||||
for (size_t i = 0; i < files.size(); ++i)
|
||||
{
|
||||
m_CachedFileData[i].Name = files[i].filename.c_str();
|
||||
m_CachedFileData[i].Name = utf16tow(files[i].filename);
|
||||
m_CachedFileData[i].NameLower = m_CachedFileData[i].Name.Lower();
|
||||
|
||||
m_CachedFileData[i].Size = wxString::Format(_T("%d"), files[i].filesize);
|
||||
@ -315,7 +318,11 @@ void ArchiveViewer::UpdateFileList()
|
||||
{
|
||||
wxDateTime date (files[i].modified.day, (wxDateTime::Month)(wxDateTime::Jan + files[i].modified.month-1), files[i].modified.year,
|
||||
files[i].modified.hour, files[i].modified.minute, files[i].modified.second, files[i].modified.msecond);
|
||||
m_CachedFileData[i].Date = wxString::Format(_T("%s %s.%03d"), date.FormatISODate(), date.FormatISOTime(), date.GetMillisecond());
|
||||
m_CachedFileData[i].Date = wxString::Format(
|
||||
_T("%s %s.%03d"),
|
||||
date.FormatISODate().c_str(),
|
||||
date.FormatISOTime().c_str(),
|
||||
date.GetMillisecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,7 +441,7 @@ void ArchiveViewer::ExtractFiles(bool onlySelected)
|
||||
for (size_t sel = 0; sel < selection.size(); ++sel)
|
||||
{
|
||||
const BAREntry& file = files[selection[sel]];
|
||||
wxString filename = file.filename.c_str();
|
||||
wxString filename = utf16tow(file.filename);
|
||||
int lastSlash = filename.Find(_T('\\'), true);
|
||||
if (lastSlash != -1)
|
||||
dirs.insert(filename.Mid(0, lastSlash+1).c_str());
|
||||
@ -452,7 +459,7 @@ void ArchiveViewer::ExtractFiles(bool onlySelected)
|
||||
{
|
||||
fullFilePath.AppendDir(filePathDirs[i]);
|
||||
if (! wxDirExists(fullFilePath.GetPath()))
|
||||
wxMkDir(fullFilePath.GetPath());
|
||||
wxMkdir(fullFilePath.GetPath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,13 +480,13 @@ void ArchiveViewer::ExtractFiles(bool onlySelected)
|
||||
|
||||
// Append name-in-archive to target root directory, one dir
|
||||
// at a time, calling mkdir at each step if necessary
|
||||
wxFileName filePath (file.filename.c_str(), wxPATH_WIN);
|
||||
wxFileName filePath (utf16tow(file.filename), wxPATH_WIN);
|
||||
filePath.MakeAbsolute(rootDir.GetPath());
|
||||
|
||||
// Output to disk
|
||||
wxFFileOutputStream outStream(filePath.GetFullPath());
|
||||
if (! outStream.Ok())
|
||||
wxLogError(wxString::Format(_("Error opening output file %s"), filePath.GetFullPath()));
|
||||
wxLogError(wxString::Format(_("Error opening output file %s"), filePath.GetFullPath().c_str()));
|
||||
else
|
||||
{
|
||||
SeekableOutputStreamFromWx str (outStream);
|
||||
@ -544,7 +551,7 @@ void ArchiveViewer::UpdatePreview(long item)
|
||||
|
||||
const BAREntry& file = m_BARReader->GetFileList()[ m_FileListCtrl->GetItemData(item) ];
|
||||
SeekableInputStream* str = m_BARReader->GetFile(file);
|
||||
m_PreviewWindow->PreviewFile(file.filename.c_str(), *str);
|
||||
m_PreviewWindow->PreviewFile(utf16tow(file.filename), *str);
|
||||
delete str;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "wx/filename.h"
|
||||
#include "wx/listctrl.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace DatafileIO
|
||||
{
|
||||
class BARReader;
|
||||
|
@ -74,7 +74,7 @@ void FilePreviewer::PreviewFile(const wxString& filename, SeekableInputStream& s
|
||||
m_MainSizer->Add(m_ContentPanel, wxSizerFlags().Expand().Proportion(1));
|
||||
|
||||
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
wxStaticText* fileInfo = new wxStaticText(m_ContentPanel, wxID_ANY, wxString::Format(_("Filename: %s"), filename));
|
||||
wxStaticText* fileInfo = new wxStaticText(m_ContentPanel, wxID_ANY, wxString::Format(_("Filename: %s"), filename.c_str()));
|
||||
sizer->Add(fileInfo, wxSizerFlags().Border(wxALL, 5));
|
||||
m_ContentPanel->SetSizer(sizer);
|
||||
|
||||
@ -179,7 +179,7 @@ void FilePreviewer::PreviewFile(const wxString& filename, SeekableInputStream& s
|
||||
formatString = _("unknown");
|
||||
|
||||
extraFileInfo = wxString::Format(_("Format: DDT texture\nSubformat: %d %d %d (%s)"),
|
||||
file.m_Type_Usage, file.m_Type_Alpha, file.m_Type_Format, formatString);
|
||||
file.m_Type_Usage, file.m_Type_Alpha, file.m_Type_Format, formatString.c_str());
|
||||
|
||||
void* buffer;
|
||||
int width, height;
|
||||
|
@ -96,7 +96,7 @@ ColourTesterColourCtrl::ColourTesterColourCtrl(wxWindow* parent, ColourTesterIma
|
||||
s >> r >> g >> b;
|
||||
text = wxColour(r,g,b);
|
||||
}
|
||||
presetColourSizer->Add(new ColouredButton(this, back, text, c["@name"], imgctrl));
|
||||
presetColourSizer->Add(new ColouredButton(this, back, text, (wxString)c["@name"], imgctrl));
|
||||
}
|
||||
|
||||
presetColourSizer->Add(new CustomColourButton(this, _("Custom"), imgctrl));
|
||||
|
@ -39,7 +39,7 @@ void ColourTesterImageCtrl::SetImageFile(const wxFileName& fn)
|
||||
|
||||
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
|
||||
ilEnable(IL_ORIGIN_SET);
|
||||
if (! ilLoadImage((TCHAR*)fn.GetFullPath().c_str()))
|
||||
if (! ilLoadImage((wchar_t*)fn.GetFullPath().c_str()))
|
||||
{
|
||||
m_Valid = false;
|
||||
Refresh();
|
||||
@ -83,7 +83,7 @@ wxString ColourTesterImageCtrl::GetImageFiletype()
|
||||
case IL_DXT4: fmt = _T("DXT4"); break;
|
||||
case IL_DXT5: fmt = _T("DXT5"); break;
|
||||
}
|
||||
return wxString::Format(_T("%s - %dx%d"), fmt, ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT));
|
||||
return wxString::Format(_T("%s - %dx%d"), fmt.c_str(), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT));
|
||||
}
|
||||
|
||||
void ColourTesterImageCtrl::SetColour(const wxColour& colour)
|
||||
|
@ -74,13 +74,13 @@ void ToolButtonBar::AddToolButton(const wxString& shortLabel, const wxString& lo
|
||||
wxFileInputStream fstr (iconPath.GetFullPath());
|
||||
if (! fstr.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str());
|
||||
return;
|
||||
}
|
||||
wxImage img (fstr, wxBITMAP_TYPE_PNG);
|
||||
if (! img.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
//#include "wx/tglbtn.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class ITool;
|
||||
class SectionLayout;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "Canvas.h"
|
||||
|
||||
#include "GameInterface/Messages.h"
|
||||
#include "ScenarioEditor/tools/Common/Tools.h"
|
||||
#include "ScenarioEditor/Tools/Common/Tools.h"
|
||||
|
||||
Canvas::Canvas(wxWindow* parent, int* attribList, long style)
|
||||
: wxGLCanvas(parent, -1, wxDefaultPosition, wxDefaultSize, style, _T("GLCanvas"), attribList),
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "wx/regex.h"
|
||||
#include "wx/config.h"
|
||||
|
||||
#include "ColourDialog.h"
|
||||
|
||||
ColourDialog::ColourDialog(wxWindow* parent, const wxString& customColourConfigPath, const wxColour& defaultColour)
|
||||
@ -17,7 +20,7 @@ ColourDialog::ColourDialog(wxWindow* parent, const wxString& customColourConfigP
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
wxString customColour;
|
||||
if (cfg->Read(wxString::Format(_T("%s%d"), m_ConfigPath, i), &customColour)
|
||||
if (cfg->Read(wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i), &customColour)
|
||||
&& re.Matches(customColour))
|
||||
{
|
||||
long r, g, b;
|
||||
@ -42,7 +45,7 @@ int ColourDialog::ShowModal()
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
wxString name = wxString::Format(_T("%s%d"), m_ConfigPath, i);
|
||||
wxString name = wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i);
|
||||
wxColour colour = GetColourData().GetCustomColour(i);
|
||||
|
||||
wxString customColour = wxString::Format(_T("%d %d %d"), colour.Red(), colour.Green(), colour.Blue());
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef COLOURDIALOG_H__
|
||||
#define COLOURDIALOG_H__
|
||||
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
class ColourDialog : public wxColourDialog
|
||||
{
|
||||
public:
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "AtlasObject/AtlasObject.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class DraggableListCtrl;
|
||||
|
||||
class DragCommand : public AtlasWindowCommand
|
||||
|
@ -187,7 +187,7 @@ void EditableListCtrl::AddRow(AtObj& obj)
|
||||
|
||||
void EditableListCtrl::AddRow(AtIter& iter)
|
||||
{
|
||||
AtObj obj = iter;
|
||||
AtObj obj = *iter;
|
||||
AddRow(obj);
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ wxString EditableListCtrl::GetCellString(long item, long column) const
|
||||
if (item >= (int)m_ListData.size())
|
||||
return _T("");
|
||||
|
||||
AtObj cell = m_ListData[item][m_ColumnTypes[column].key];
|
||||
AtObj cell = *m_ListData[item][m_ColumnTypes[column].key];
|
||||
return AtlasObject::ConvertToString(cell).c_str();
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ AtObj EditableListCtrl::GetCellObject(long item, long column) const
|
||||
if (item >= (int)m_ListData.size())
|
||||
return AtObj();
|
||||
|
||||
return m_ListData[item][m_ColumnTypes[column].key];
|
||||
return *m_ListData[item][m_ColumnTypes[column].key];
|
||||
}
|
||||
|
||||
void EditableListCtrl::SetCellString(long item, long column, wxString& str)
|
||||
@ -280,7 +280,7 @@ void EditableListCtrl::ThawData(AtObj& in)
|
||||
{
|
||||
m_ListData.clear();
|
||||
for (AtIter it = in["item"]; it.defined(); ++it)
|
||||
m_ListData.push_back(it);
|
||||
m_ListData.push_back(*it);
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "AtlasObject/AtlasObject.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class EditableListCtrl;
|
||||
|
||||
class EditCommand_Dialog : public AtlasWindowCommand
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
void FieldEditCtrl_Text::StartEdit(wxWindow* parent, wxRect rect, long row, int col)
|
||||
{
|
||||
new QuickTextCtrl(parent, rect, ListCtrlValidator((EditableListCtrl*)parent, row, col));
|
||||
ListCtrlValidator validator((EditableListCtrl*)parent, row, col);
|
||||
new QuickTextCtrl(parent, rect, validator);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -74,9 +75,10 @@ void FieldEditCtrl_List::StartEdit(wxWindow* parent, wxRect rect, long row, int
|
||||
|
||||
AtObj list (Datafile::ReadList(m_ListType));
|
||||
for (AtIter it = list["item"]; it.defined(); ++it)
|
||||
choices.Add(it);
|
||||
choices.Add((wxString)it);
|
||||
|
||||
new QuickComboBox(parent, rect, choices, ListCtrlValidator((EditableListCtrl*)parent, row, col));
|
||||
ListCtrlValidator validator((EditableListCtrl*)parent, row, col);
|
||||
new QuickComboBox(parent, rect, choices, validator);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -127,5 +129,6 @@ FieldEditCtrl_File::FieldEditCtrl_File(const wxString& rootDir, const wxString&
|
||||
|
||||
void FieldEditCtrl_File::StartEdit(wxWindow* parent, wxRect rect, long row, int col)
|
||||
{
|
||||
new QuickFileCtrl(parent, rect, m_RootDir, m_FileMask, m_RememberedDir, ListCtrlValidator((EditableListCtrl*)parent, row, col));
|
||||
ListCtrlValidator validator((EditableListCtrl*)parent, row, col);
|
||||
new QuickFileCtrl(parent, rect, m_RootDir, m_FileMask, m_RememberedDir, validator);
|
||||
}
|
@ -2,10 +2,15 @@
|
||||
|
||||
#include "HighResTimer.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
// TODO: Portability and general betterness. (But it's good enough for now.)
|
||||
|
||||
HighResTimer::HighResTimer()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER freq;
|
||||
BOOL ok = QueryPerformanceFrequency(&freq);
|
||||
if (! ok)
|
||||
@ -16,10 +21,12 @@ HighResTimer::HighResTimer()
|
||||
{
|
||||
m_TickLength = freq.QuadPart;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
double HighResTimer::GetTime()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER count;
|
||||
BOOL ok = QueryPerformanceCounter(&count);
|
||||
if (! ok)
|
||||
@ -28,4 +35,9 @@ double HighResTimer::GetTime()
|
||||
return 0.0;
|
||||
}
|
||||
return (double)count.QuadPart / (double)m_TickLength.GetValue();
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec+(tv.tv_usec/1000000.0);
|
||||
#endif
|
||||
}
|
||||
|
@ -12,6 +12,10 @@
|
||||
|
||||
class SaveOnExitDialog : public wxDialog
|
||||
{
|
||||
#ifndef _WIN32
|
||||
#define EndDialog EndModal
|
||||
#endif
|
||||
|
||||
public:
|
||||
SaveOnExitDialog(wxWindow* parent, bool allowCancel)
|
||||
: wxDialog(parent, wxID_ANY, (wxString) _("Save changes?"))
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include <boost/signal.hpp>
|
||||
|
||||
class AtObj;
|
||||
|
||||
class AtlasWindow : public wxFrame, public IAtlasSerialiser
|
||||
|
@ -23,7 +23,7 @@ AtObj Datafile::ReadList(const char* section)
|
||||
|
||||
AtObj lists (AtlasObject::LoadFromXML(filename.GetFullPath()));
|
||||
|
||||
return lists["lists"][section];
|
||||
return *lists["lists"][section];
|
||||
}
|
||||
|
||||
void Datafile::SetSystemDirectory(const wxString& dir)
|
||||
|
@ -41,9 +41,9 @@ namespace AtlasMessage
|
||||
|
||||
// Global variables, to remember state between DllMain and StartWindow and OnInit
|
||||
wxString g_InitialWindowType;
|
||||
HINSTANCE g_Module;
|
||||
bool g_IsLoaded = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE g_Module;
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved))
|
||||
{
|
||||
@ -64,6 +64,7 @@ BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpRese
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace AtlasMessage;
|
||||
|
||||
@ -77,7 +78,13 @@ ATLASDLLIMPEXP void Atlas_SetMessagePasser(MessagePasser* passer)
|
||||
ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
|
||||
{
|
||||
g_InitialWindowType = type;
|
||||
#ifdef _WIN32
|
||||
wxEntry(g_Module);
|
||||
#else
|
||||
int argc=1;
|
||||
char *argv[]={"atlas", NULL};
|
||||
wxEntry(argc, argv);
|
||||
#endif
|
||||
}
|
||||
|
||||
ATLASDLLIMPEXP void Atlas_DisplayError(const wchar_t* text, unsigned int WXUNUSED(flags))
|
||||
@ -161,6 +168,7 @@ public:
|
||||
|
||||
bool OpenDirectory(const wxString& dir)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Code largely copied from wxLaunchDefaultBrowser:
|
||||
// (TODO: portability)
|
||||
|
||||
@ -193,6 +201,11 @@ public:
|
||||
::FreeLibrary(hShellDll);
|
||||
|
||||
return true;
|
||||
#else
|
||||
// Figure out what goes for "default browser" on unix/linux/whatever
|
||||
// open an xterm perhaps? :)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void OnFatalException()
|
||||
|
@ -62,8 +62,13 @@
|
||||
|
||||
#ifndef HAVE_PCH
|
||||
// If no PCH, just include a load of common headers anyway
|
||||
# include "wx/defs.h"
|
||||
# include "wx/string.h"
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ATLASDLLIMPEXP extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define ATLASDLLIMPEXP extern "C"
|
||||
#endif
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "wx/image.h"
|
||||
#include "wx/busyinfo.h"
|
||||
#include "wx/mediactrl.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include "General/AtlasEventLoop.h"
|
||||
#include "General/Datafile.h"
|
||||
@ -18,7 +19,7 @@
|
||||
#include "GameInterface/MessagePasser.h"
|
||||
#include "GameInterface/Messages.h"
|
||||
|
||||
#include "tools/Common/Tools.h"
|
||||
#include "Tools/Common/Tools.h"
|
||||
|
||||
static HighResTimer g_Timer;
|
||||
|
||||
@ -235,7 +236,7 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(MediaPlayer, wxFrame)
|
||||
EVT_MEDIA_LOADED(wxID_ANY, OnLoad)
|
||||
EVT_MEDIA_LOADED(wxID_ANY, MediaPlayer::OnLoad)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -379,10 +380,13 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
|
||||
};
|
||||
Canvas* canvas = new GameCanvas(m_SectionLayout.GetCanvasParent(), glAttribList);
|
||||
m_SectionLayout.SetCanvas(canvas);
|
||||
|
||||
#ifdef _WIN32
|
||||
// The canvas' context gets made current on creation; but it can only be
|
||||
// current for one thread at a time, and it needs to be current for the
|
||||
// thread that is doing the draw calls, so disable it for this one.
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
#endif
|
||||
|
||||
// Set up sidebars:
|
||||
|
||||
@ -390,6 +394,12 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
|
||||
|
||||
// Send setup messages to game engine:
|
||||
|
||||
/*canvas->Reparent(parent);
|
||||
//canvas->SetCurrent();
|
||||
canvas->Show(TRUE);*/
|
||||
|
||||
printf("posting setcontext with canvas %p\n", canvas->GetContext());
|
||||
if (canvas->GetContext() != 0)
|
||||
POST_MESSAGE(SetContext, (canvas->GetContext()));
|
||||
|
||||
POST_MESSAGE(Init, (true));
|
||||
@ -558,7 +568,7 @@ void ScenarioEditor::OnSaveAs(wxCommandEvent& WXUNUSED(event))
|
||||
void ScenarioEditor::SetOpenFilename(const wxString& filename)
|
||||
{
|
||||
SetTitle(wxString::Format(_("Atlas - Scenario Editor - %s"),
|
||||
filename.IsEmpty() ? _("(untitled)") : filename));
|
||||
(filename.IsEmpty() ? wxString(_("(untitled)")) : filename).c_str()));
|
||||
|
||||
m_OpenFilename = filename;
|
||||
}
|
||||
@ -627,6 +637,7 @@ static void QueryCallback()
|
||||
// GUI in any other way) when it's running under Atlas, so we wouldn't need
|
||||
// to do any message processing here at all?)
|
||||
|
||||
#ifdef _WIN32
|
||||
AtlasEventLoop* evtLoop = (AtlasEventLoop*)wxEventLoop::GetActive();
|
||||
|
||||
// evtLoop might be NULL, particularly if we're still initialising windows
|
||||
@ -678,6 +689,7 @@ static void QueryCallback()
|
||||
evtLoop->AddMessage(pMsg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
void QueryMessage::Post()
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "wx/filename.h"
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
#include "SectionLayout.h"
|
||||
|
||||
#include "SnapSplitterWindow/SnapSplitterWindow.h"
|
||||
@ -85,14 +88,14 @@ public:
|
||||
wxFileInputStream fstr (iconPath.GetFullPath());
|
||||
if (! fstr.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
img = wxImage(fstr, wxBITMAP_TYPE_PNG);
|
||||
if (! img.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str());
|
||||
img = wxImage (1, 1, true);
|
||||
}
|
||||
}
|
||||
@ -261,7 +264,7 @@ void SectionLayout::Build()
|
||||
if (sidebar->GetBottomBar()) \
|
||||
sidebar->GetBottomBar()->Show(false); \
|
||||
m_SidebarBook->AddPage(sidebar, icon, tooltip); \
|
||||
m_PageMappings.insert(std::make_pair(L#classname, (int)m_SidebarBook->GetPageCount()-1));
|
||||
m_PageMappings.insert(std::make_pair(L###classname, (int)m_SidebarBook->GetPageCount()-1));
|
||||
|
||||
ADD_SIDEBAR(MapSidebar, _T("map.png"), _("Map"));
|
||||
ADD_SIDEBAR(TerrainSidebar, _T("terrain.png"), _("Terrain"));
|
||||
|
@ -1,8 +1,12 @@
|
||||
#ifndef SECTIONLAYOUT_H__
|
||||
#define SECTIONLAYOUT_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class SnapSplitterWindow;
|
||||
class SidebarBook;
|
||||
class wxWindow;
|
||||
|
||||
class SectionLayout
|
||||
{
|
||||
|
@ -5,9 +5,14 @@
|
||||
#include "GameInterface/Messages.h"
|
||||
#include "CustomControls/Buttons/ActionButton.h"
|
||||
//#include "CustomControls/Buttons/FloatingSpinCtrl.h"
|
||||
#include "General/DataFile.h"
|
||||
#include "General/Datafile.h"
|
||||
#include "ScenarioEditor/Tools/Common/Tools.h"
|
||||
#include "HighResTimer/HighResTimer.h"
|
||||
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace AtlasMessage;
|
||||
@ -683,7 +688,7 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(TrackSlider, wxSlider)
|
||||
EVT_SCROLL(OnScroll)
|
||||
EVT_SCROLL(TrackSlider::OnScroll)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
class PathSlider : public wxSlider
|
||||
@ -710,7 +715,7 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(PathSlider, wxSlider)
|
||||
EVT_SCROLL(OnScroll)
|
||||
EVT_SCROLL(PathSlider::OnScroll)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
class CinemaSliderBox : public wxPanel
|
||||
@ -765,7 +770,7 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(CinemaSliderBox, wxPanel)
|
||||
EVT_TIMER(wxID_ANY, OnTick)
|
||||
EVT_TIMER(wxID_ANY, CinemaSliderBox::OnTick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TrackSlider::OnScroll(wxScrollEvent& WXUNUSED(event))
|
||||
@ -1128,14 +1133,14 @@ wxImage CinematicSidebar::LoadIcon(const wxString& filename)
|
||||
wxFileInputStream fstr (iconPath.GetFullPath());
|
||||
if (! fstr.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to open cinematic icon file '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to open cinematic icon file '%s'"), iconPath.GetFullPath().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
img = wxImage(fstr, wxBITMAP_TYPE_BMP);
|
||||
if (! img.Ok())
|
||||
{
|
||||
wxLogError(_("Failed to load cinematic icon image '%s'"), iconPath.GetFullPath());
|
||||
wxLogError(_("Failed to load cinematic icon image '%s'"), iconPath.GetFullPath().c_str());
|
||||
img = wxImage (1, 1, true);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(VariableSliderBox, wxPanel)
|
||||
EVT_SCROLL(OnScroll)
|
||||
EVT_SCROLL(VariableSliderBox::OnScroll)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -109,7 +109,7 @@ private:
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(VariableListBox, wxPanel)
|
||||
EVT_COMBOBOX(wxID_ANY, OnSelect)
|
||||
EVT_COMBOBOX(wxID_ANY, VariableListBox::OnSelect)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -173,7 +173,7 @@ private:
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(VariableColourBox, wxPanel)
|
||||
EVT_BUTTON(wxID_ANY, OnClick)
|
||||
EVT_BUTTON(wxID_ANY, VariableColourBox::OnClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "LightControl.h"
|
||||
|
||||
using AtlasMessage::Shareable;
|
||||
@ -53,7 +55,7 @@ public:
|
||||
float rdotl = rx*lx + ry*ly + rz*lz;
|
||||
|
||||
int diffuse = (int)std::max(0.f, ndotl*128.f);
|
||||
int specular = (int)std::min(255.f, 64.f*pow(std::max(0.f, rdotl), 16.f));
|
||||
int specular = (int)std::min(255., 64.f*pow(std::max(0.f, rdotl), 16.f));
|
||||
|
||||
imgData[0] = std::min(64+diffuse+specular, 255);
|
||||
imgData[1] = std::min(48+diffuse+specular, 255);
|
||||
@ -70,7 +72,11 @@ public:
|
||||
}
|
||||
|
||||
wxPaintDC dc(this);
|
||||
#if OS_WIN
|
||||
dc.DrawBitmap(wxBitmap(img, dc), 0, 0);
|
||||
#else
|
||||
dc.DrawBitmap(wxBitmap(img), 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnMouse(wxMouseEvent& event)
|
||||
|
@ -158,7 +158,7 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
BEGIN_EVENT_TABLE(PlayerComboBox, wxComboBox)
|
||||
EVT_COMBOBOX(wxID_ANY, OnSelect)
|
||||
EVT_COMBOBOX(wxID_ANY, PlayerComboBox::OnSelect)
|
||||
END_EVENT_TABLE();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -5,6 +5,8 @@ class BrushShapeCtrl;
|
||||
class BrushSizeCtrl;
|
||||
class BrushStrengthCtrl;
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Brush
|
||||
{
|
||||
friend class BrushShapeCtrl;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef ObjectSettings_H__
|
||||
#define ObjectSettings_H__
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "ScenarioEditor/Tools/Common/MiscState.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define TOOLS_H__
|
||||
|
||||
#include "ScenarioEditor/ScenarioEditor.h"
|
||||
#include "general/AtlasWindowCommand.h"
|
||||
#include "General/AtlasWindowCommand.h"
|
||||
|
||||
class wxMouseEvent;
|
||||
class wxKeyEvent;
|
||||
|
@ -48,7 +48,7 @@ bool BARReader::Initialise()
|
||||
|
||||
m_Stream.Seek(filetableOffset, Stream::FROM_START);
|
||||
|
||||
std::wstring rootName = ReadUString(m_Stream);
|
||||
utf16string rootName = ReadUString(m_Stream);
|
||||
uint32_t numRootFiles;
|
||||
m_Stream.Read(&numRootFiles, 4);
|
||||
CHECK(numRootFiles == numFiles);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Util.h"
|
||||
|
||||
namespace DatafileIO
|
||||
{
|
||||
class SeekableInputStream;
|
||||
@ -8,7 +10,7 @@ namespace DatafileIO
|
||||
|
||||
struct BAREntry
|
||||
{
|
||||
std::wstring filename; // includes root name - e.g. "Data\tactics\warwagon.tactics.xmb"
|
||||
utf16string filename; // includes root name - e.g. "Data\tactics\warwagon.tactics.xmb"
|
||||
size_t filesize; // in bytes
|
||||
struct {
|
||||
unsigned short year, month, day, dayofweek; // 2005 etc, 1..12, 1..31, 0..6 (from Sunday)
|
||||
|
@ -34,10 +34,12 @@ struct DDTImage
|
||||
size_t length;
|
||||
};
|
||||
|
||||
#ifdef USE_DEVIL_DXT
|
||||
static void LoadDXT(int dxtType, unsigned char* oldData);
|
||||
static void SaveDXT(int dxtType); // saves the currently bound image
|
||||
static void ToggleOrigin(); // urgh
|
||||
static void SwizzleAGBR();
|
||||
#endif
|
||||
static void ToggleOrigin(); // urgh
|
||||
|
||||
bool DDTFile::Read(FileType type)
|
||||
{
|
||||
@ -110,6 +112,7 @@ bool DDTFile::Read(FileType type)
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef USE_DEVIL_DXT
|
||||
case DXT1:
|
||||
case DXT3:
|
||||
case NORMSPEC:
|
||||
@ -124,6 +127,7 @@ bool DDTFile::Read(FileType type)
|
||||
delete[] oldData;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GREY:
|
||||
{
|
||||
@ -349,6 +353,7 @@ bool DDTFile::SaveFile(OutputStream& stream, FileType outputType)
|
||||
delete[] newData;
|
||||
break;
|
||||
}
|
||||
#ifdef USE_DEVIL_DXT
|
||||
case DXT1:
|
||||
SaveDXT(1);
|
||||
break;
|
||||
@ -359,6 +364,7 @@ bool DDTFile::SaveFile(OutputStream& stream, FileType outputType)
|
||||
SwizzleAGBR();
|
||||
SaveDXT(5);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
ilDeleteImages(1, &img);
|
||||
@ -372,18 +378,6 @@ bool DDTFile::SaveFile(OutputStream& stream, FileType outputType)
|
||||
|
||||
|
||||
|
||||
static void SwizzleAGBR()
|
||||
{
|
||||
ILubyte* data = ilGetData();
|
||||
ILint pixels = ilGetInteger(IL_IMAGE_WIDTH)*ilGetInteger(IL_IMAGE_HEIGHT);
|
||||
for (ILint i = 0; i < pixels; ++i)
|
||||
{
|
||||
ILubyte t = data[i*4+0];
|
||||
data[i*4+0] = data[i*4+3];
|
||||
data[i*4+3] = t;
|
||||
}
|
||||
}
|
||||
|
||||
// Evilness:
|
||||
#include "IL/devil_internal_exports.h"
|
||||
extern "C"
|
||||
@ -392,10 +386,20 @@ extern "C"
|
||||
extern ILboolean DecompressDXT3();
|
||||
extern ILboolean DecompressDXT5();
|
||||
extern ILuint Compress(ILimage* Image, ILenum DXTCFormat);
|
||||
extern ILimage* iCurImage;
|
||||
}
|
||||
|
||||
static void ToggleOrigin()
|
||||
{
|
||||
iCurImage->Origin = (iCurImage->Origin == IL_ORIGIN_UPPER_LEFT ? IL_ORIGIN_LOWER_LEFT : IL_ORIGIN_UPPER_LEFT);
|
||||
}
|
||||
|
||||
#ifdef USE_DEVIL_DXT
|
||||
extern "C"
|
||||
{
|
||||
extern ILubyte* CompData;
|
||||
extern ILint Depth, Width, Height;
|
||||
extern ILimage* Image;
|
||||
extern ILimage* iCurImage;
|
||||
}
|
||||
|
||||
static void LoadDXT(int dxtType, unsigned char* oldData)
|
||||
@ -419,12 +423,21 @@ static void LoadDXT(int dxtType, unsigned char* oldData)
|
||||
Image = NULL;
|
||||
}
|
||||
|
||||
static void SwizzleAGBR()
|
||||
{
|
||||
ILubyte* data = ilGetData();
|
||||
ILint pixels = ilGetInteger(IL_IMAGE_WIDTH)*ilGetInteger(IL_IMAGE_HEIGHT);
|
||||
for (ILint i = 0; i < pixels; ++i)
|
||||
{
|
||||
ILubyte t = data[i*4+0];
|
||||
data[i*4+0] = data[i*4+3];
|
||||
data[i*4+3] = t;
|
||||
}
|
||||
}
|
||||
|
||||
static void SaveDXT(int dxtType)
|
||||
{
|
||||
Compress(ilGetCurImage(), dxtType==1 ? IL_DXT1 : dxtType==3 ? IL_DXT3 : IL_DXT5);
|
||||
}
|
||||
|
||||
static void ToggleOrigin()
|
||||
{
|
||||
iCurImage->Origin = (iCurImage->Origin == IL_ORIGIN_UPPER_LEFT ? IL_ORIGIN_LOWER_LEFT : IL_ORIGIN_UPPER_LEFT);
|
||||
}
|
||||
#endif
|
||||
|
@ -23,3 +23,18 @@ void DatafileIO::WriteUString(OutputStream& stream, const utf16string& string)
|
||||
stream.Write(&length, 4);
|
||||
stream.Write((utf16_t*)&string[0], length*2);
|
||||
}
|
||||
|
||||
#if !OS_WIN
|
||||
// TODO In reality, these two should be able to de/encode UTF-16 to/from UCS-4
|
||||
// instead of just treating UTF-16 as UCS-2
|
||||
|
||||
std::wstring DatafileIO::utf16tow(const utf16string &str)
|
||||
{
|
||||
return std::wstring(str.begin(), str.end());
|
||||
}
|
||||
|
||||
utf16string DatafileIO::wtoutf16(const std::wstring &str)
|
||||
{
|
||||
return utf16string(str.begin(), str.end());
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#if OS_UNIX
|
||||
#include "ps/utf16string.h"
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifndef C_ASSERT
|
||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
||||
@ -7,12 +11,17 @@
|
||||
|
||||
namespace DatafileIO
|
||||
{
|
||||
#if OS_WIN
|
||||
// TODO: proper portability
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef std::wstring utf16string;
|
||||
typedef wchar_t utf16_t;
|
||||
#else
|
||||
typedef uint16_t utf16_t;
|
||||
typedef std::basic_string<utf16_t> utf16string;
|
||||
#endif
|
||||
|
||||
C_ASSERT(sizeof(int32_t) == 4);
|
||||
C_ASSERT(sizeof(uint32_t) == 4);
|
||||
@ -25,4 +34,12 @@ namespace DatafileIO
|
||||
// Read/write 4-byte length + UCS-2 string
|
||||
utf16string ReadUString(InputStream& stream);
|
||||
void WriteUString(OutputStream& stream, const utf16string& string);
|
||||
|
||||
#if OS_WIN
|
||||
# define utf16tow(_str) _str
|
||||
# define wtoutf16(_str) _str
|
||||
#else
|
||||
std::wstring utf16tow(const utf16string &str);
|
||||
utf16string wtoutf16(const std::wstring &str);
|
||||
#endif
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <xercesc/util/BinInputStream.hpp>
|
||||
#include <xercesc/sax/SAXParseException.hpp>
|
||||
#include <xercesc/sax/InputSource.hpp>
|
||||
#include <xercesc/util/BinInputStream.hpp>
|
||||
#include <xercesc/sax/ErrorHandler.hpp>
|
||||
#include <xercesc/sax2/XMLReaderFactory.hpp>
|
||||
#include <xercesc/sax2/DefaultHandler.hpp>
|
||||
@ -330,11 +331,11 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
output += L"\n";
|
||||
output += indent;
|
||||
output += L"<";
|
||||
output += node->name; // TODO: utf16->w
|
||||
output += utf16tow(node->name);
|
||||
|
||||
for (size_t i = 0; i < node->attrs.size(); ++i)
|
||||
{
|
||||
std::wstring value = node->attrs[i].value;
|
||||
std::wstring value = utf16tow(node->attrs[i].value);
|
||||
// Escape funny characters
|
||||
if (value.find_first_of(L"&<>\"") != value.npos)
|
||||
{
|
||||
@ -345,7 +346,7 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
}
|
||||
|
||||
output += L" ";
|
||||
output += node->attrs[i].name;
|
||||
output += utf16tow(node->attrs[i].name);
|
||||
output += L"=\"";
|
||||
output += value;
|
||||
output += L"\"";
|
||||
@ -353,9 +354,10 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
|
||||
// Output the element's contents, in an attemptedly nice readable format:
|
||||
|
||||
std::wstring name = utf16tow(node->name);
|
||||
if (node->text.length())
|
||||
{
|
||||
std::wstring text = node->text;
|
||||
std::wstring text = utf16tow(node->text);
|
||||
|
||||
// Wrap text in CDATA when necessary. (Maybe we should use < etc
|
||||
// in some cases?)
|
||||
@ -392,7 +394,7 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
output += L"\n";
|
||||
output += indent;
|
||||
output += L"</";
|
||||
output += node->name;
|
||||
output += name;
|
||||
output += L">";
|
||||
}
|
||||
else
|
||||
@ -401,7 +403,7 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
output += L">";
|
||||
output += text;
|
||||
output += L"</";
|
||||
output += node->name;
|
||||
output += name;
|
||||
output += L">";
|
||||
}
|
||||
}
|
||||
@ -419,7 +421,7 @@ void OutputNode(std::wstring& output, const XMLElement* node, const std::wstring
|
||||
output += L"\n";
|
||||
output += indent;
|
||||
output += L"</";
|
||||
output += node->name;
|
||||
output += name;
|
||||
output += L">";
|
||||
}
|
||||
else
|
||||
@ -482,11 +484,13 @@ public:
|
||||
utf16string getErrorText() { return errorText; }
|
||||
private:
|
||||
bool sawErrors;
|
||||
std::wstring errorText;
|
||||
utf16string errorText;
|
||||
void complain(const SAXParseException& err, const wchar_t* severity) {
|
||||
sawErrors = true;
|
||||
C_ASSERT(sizeof(wchar_t) == sizeof(XMLCh));
|
||||
errorText += (std::wstring)L"XML "+severity+L": "+ (wchar_t*)err.getSystemId() + L" / " + (wchar_t*)err.getMessage();
|
||||
C_ASSERT(sizeof(utf16_t) == sizeof(XMLCh));
|
||||
errorText += wtoutf16(L"XML ")+wtoutf16(severity)
|
||||
+wtoutf16(L": ")+ (utf16_t*)err.getSystemId()
|
||||
+wtoutf16(L" / ") + (utf16_t*)err.getMessage();
|
||||
}
|
||||
};
|
||||
|
||||
@ -539,7 +543,8 @@ XMBFile* DatafileIO::XMLReader::LoadFromXML(InputStream& stream)
|
||||
|
||||
|
||||
// Build the XMLElement tree inside the XeroHandler
|
||||
Parser->parse(XeroInputSource(stream));
|
||||
XeroInputSource src(stream);
|
||||
Parser->parse(src);
|
||||
|
||||
delete Parser;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "CommandProc.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
|
@ -112,6 +112,7 @@ MESSAGEHANDLER(SetActorViewer)
|
||||
MESSAGEHANDLER(SetContext)
|
||||
{
|
||||
g_GameLoop->glContext = msg->context;
|
||||
printf("Setting gl context to %p\n", g_GameLoop->glContext);
|
||||
Atlas_GLSetCurrent((void*)g_GameLoop->glContext);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "MessagesSetup.h"
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// TODO: organisation, documentation, etc
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -15,7 +18,7 @@ MESSAGE(Init,
|
||||
|
||||
MESSAGE(Shutdown, );
|
||||
|
||||
struct eRenderView { enum { NONE, GAME, ACTOR }; };
|
||||
struct eRenderView { enum renderViews { NONE, GAME, ACTOR }; };
|
||||
|
||||
MESSAGE(RenderEnable,
|
||||
((int, view)) // eRenderView
|
||||
|
@ -12,6 +12,9 @@
|
||||
#include "SharedTypes.h"
|
||||
#include "Shareable.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace AtlasMessage
|
||||
{
|
||||
|
||||
|
@ -42,6 +42,8 @@ after their definition.
|
||||
|
||||
#include "SharedMemory.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// We want to use placement new, which breaks when compiling Debug configurations
|
||||
// in the game and in wx, and they both need different workarounds.
|
||||
// (Duplicated in SharedMemory.h)
|
||||
|
Loading…
Reference in New Issue
Block a user