1
0
forked from 0ad/0ad

Atlas: Fixes for compiler warnings and UI layout issues on Windows. Fixed territory updates when deleting units.

This was SVN commit r5176.
This commit is contained in:
Ykkrosh 2007-06-14 15:42:24 +00:00
parent 047b1ca21d
commit 5ef98758b2
15 changed files with 67 additions and 44 deletions

View File

@ -87,9 +87,11 @@ TerrainPreviewPage.prototype = {
var hit = list.hitTest(evt.position);
var tip = undefined;
if (hit.item != -1 && (hit.flags & wxListHitTest.ONITEMICON))
{
tip = names[hit.item]
if (list.toolTip !== tip)
list.toolTip = tip;
}
};
list.onItemSelected = function(evt) {
Atlas.SetSelectedTexture(names[evt.index]);
@ -97,6 +99,8 @@ TerrainPreviewPage.prototype = {
list.setImageList(imglist, wxListCtrl.NORMAL);
this.panel.layout();
this.loaded = true;
}
};
@ -159,7 +163,7 @@ function init(window, bottomWindow)
];
var shapeNames = [];
for each (var s in shapes) shapeNames.push(s[0]);
var shapeBox = new wxRadioBox(window, -1, 'Shape', wxDefaultPosition, wxDefaultSize, shapeNames);
var shapeBox = new wxRadioBox(window, -1, 'Shape', wxDefaultPosition, wxDefaultSize, shapeNames, 0, wxRadioBox.SPECIFY_ROWS);
brushSizer.add(shapeBox);
shapeBox.onRadioBox = function(evt)
{
@ -194,9 +198,11 @@ function init(window, bottomWindow)
var nb = new wxNotebook(bottomWindow, -1);
bottomWindow.sizer = new wxBoxSizer(wxOrientation.VERTICAL);
bottomWindow.sizer.add(nb, 1, wxStretch.EXPAND);
var pages = [];
nb.onPageChanged = function (evt) {
pages[evt.selection].display()
evt.skip = true;
}
for each (var groupname in terrainGroups.groupnames)
{

View File

@ -85,8 +85,8 @@ struct ScriptInterface_NativeWrapper<void> {
// JSNative-compatible function that wraps the function identified in the template argument list
#define OVERLOADS(z, i, data) \
template <typename TR, TYPENAME_T0_HEAD(z,i) TR (*fptr) ( T0(z,i) )> \
JSBool ScriptInterface::call(JSContext* cx, JSObject* /*obj*/, uintN argc, jsval* argv, jsval* rval) { \
(void)argc; (void)argv; /* avoid 'unused parameter' warnings */ \
JSBool ScriptInterface::call(JSContext* cx, JSObject* /*obj*/, uintN /*argc*/, jsval* argv, jsval* rval) { \
(void)argv; /* avoid 'unused parameter' warnings */ \
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
ScriptInterface_NativeWrapper<TR>::call(cx, *rval, fptr A0_TAIL(z,i)); \
return JS_TRUE; \

View File

@ -131,7 +131,7 @@ namespace
if (! JS_GetArrayLength(cx, obj, &length))
FAIL("Failed to get array length");
out.reserve(length);
for (jsint i = 0; i < length; ++i)
for (jsuint i = 0; i < length; ++i)
{
jsval el;
if (! JS_GetElement(cx, obj, i, &el))
@ -149,7 +149,7 @@ namespace
template<typename T> struct ToJSVal
{
static jsval Convert(JSContext* cx, const T& val)
static jsval Convert(JSContext* cx, const T& WXUNUSED(val))
{
JS_ReportError(cx, "Unrecognised query return type");
return JSVAL_VOID;
@ -214,7 +214,7 @@ namespace
for (size_t i = 0; i < val.size(); ++i)
{
jsval el = ToJSVal<T>::Convert(cx, val[i]);
JS_SetElement(cx, obj, i, &el);
JS_SetElement(cx, obj, (jsint)i, &el);
}
JS_RemoveRoot(cx, &obj);
return OBJECT_TO_JSVAL(obj);
@ -499,16 +499,18 @@ std::pair<wxPanel*, wxPanel*> ScriptInterface::LoadScriptAsSidebar(const wxStrin
#define ARG_LIST(r, data, i, elem) BOOST_PP_COMMA_IF(i) a##i
#define MESSAGE(name, vals) \
JSBool call_##name(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* WXUNUSED(rval)) \
JSBool call_##name(JSContext* cx, JSObject* WXUNUSED(obj), uintN WXUNUSED(argc), jsval* argv, jsval* WXUNUSED(rval)) \
{ \
(void)cx; (void)argv; /* avoid 'unused parameter' warnings */ \
BOOST_PP_SEQ_FOR_EACH_I(CONVERT_ARGS, ~, vals) \
g_MessagePasser->Add(SHAREABLE_NEW(m##name, ( BOOST_PP_SEQ_FOR_EACH_I(ARG_LIST, ~, vals) ))); \
return JS_TRUE; \
}
#define QUERY(name, in_vals, out_vals) \
JSBool call_##name(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) \
JSBool call_##name(JSContext* cx, JSObject* WXUNUSED(obj), uintN WXUNUSED(argc), jsval* argv, jsval* rval) \
{ \
(void)argv; /* avoid 'unused parameter' warnings */ \
BOOST_PP_SEQ_FOR_EACH_I(CONVERT_ARGS, ~, in_vals) \
q##name q = q##name( BOOST_PP_SEQ_FOR_EACH_I(ARG_LIST, ~, in_vals) ); \
q.Post(); \

View File

@ -238,9 +238,12 @@ public:
virtual void OnFirstDisplay()
{
Freeze();
std::pair<wxPanel*, wxPanel*> panels = m_ScenarioEditor.GetScriptInterface().LoadScriptAsSidebar(_T("section/") + m_Name, this, m_BottomBarContainer);
m_MainSizer->Add(panels.first, wxSizerFlags(1).Expand());
m_BottomBar = panels.second;
Layout();
Thaw();
}
private:
wxString m_Name;

View File

@ -142,7 +142,6 @@ MESSAGEHANDLER(SetActorViewer)
MESSAGEHANDLER(SetCanvas)
{
g_GameLoop->glCanvas = msg->canvas;
printf("Setting gl canvas to %p\n", g_GameLoop->glCanvas);
Atlas_GLSetCurrent(const_cast<void*>(g_GameLoop->glCanvas));
}

View File

@ -727,8 +727,13 @@ BEGIN_COMMAND(DeleteObject)
if (unit->GetEntity())
{
bool wasTerritoryCentre = unit->GetEntity()->m_base->m_isTerritoryCentre;
m_FrozenEntity.reset(new SimState::Entity( SimState::Entity::Freeze(unit) ));
unit->GetEntity()->Kill();
if (wasTerritoryCentre)
g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate();
}
else
{
@ -741,10 +746,10 @@ BEGIN_COMMAND(DeleteObject)
{
if (m_FrozenEntity.get())
{
m_FrozenEntity->Thaw();
CEntity* entity = m_FrozenEntity->Thaw();
// XXXif (m_UnitInLimbo->GetEntity()->m_base->m_isTerritoryCentre)
//g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate();
if (entity && entity->m_base->m_isTerritoryCentre)
g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate();
m_FrozenEntity.reset();
}

View File

@ -32,19 +32,20 @@ SimState::Entity SimState::Entity::Freeze(CUnit* unit)
return e;
}
void SimState::Entity::Thaw()
CEntity* SimState::Entity::Thaw()
{
CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate(templateName, g_Game->GetPlayer(playerID));
if (! base)
return;
return NULL;
HEntity ent = g_EntityManager.Create(base, position, angle, selections);
if (! ent)
return;
return NULL;
ent->m_actor->SetPlayerID(playerID);
ent->m_actor->SetID(unitID);
ent->Initialize();
return ent;
}
SimState::Nonentity SimState::Nonentity::Freeze(CUnit* unit)
@ -59,18 +60,19 @@ SimState::Nonentity SimState::Nonentity::Freeze(CUnit* unit)
return n;
}
void SimState::Nonentity::Thaw()
CUnit* SimState::Nonentity::Thaw()
{
CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager();
CUnit* unit = unitMan.CreateUnit(actorName, NULL, selections);
if (! unit)
return;
return NULL;
CMatrix3D m;
m.SetYRotation(angle + PI);
m.Translate(position);
unit->GetModel()->SetTransform(m);
unit->SetID(unitID);
return unit;
}
SimState* SimState::Freeze(bool onlyEntities)
@ -112,9 +114,6 @@ void SimState::Thaw()
CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager();
// delete all existing entities
g_Game;
g_Game->GetWorld();
g_Game->GetWorld()->GetProjectileManager();
g_Game->GetWorld()->GetProjectileManager().DeleteAll();
g_EntityManager.DeleteAll();

View File

@ -2,6 +2,7 @@
#define SIMSTATE_INCLUDED
class CUnit;
class CEntity;
#include "maths/Vector3D.h"
class SimState
@ -11,7 +12,7 @@ public:
{
public:
static Entity Freeze(CUnit* unit);
void Thaw();
CEntity* Thaw();
private:
CStrW templateName;
int unitID;
@ -25,7 +26,7 @@ public:
{
public:
static Nonentity Freeze(CUnit* unit);
void Thaw();
CUnit* Thaw();
private:
CStrW actorName;
int unitID;

View File

@ -63,9 +63,6 @@ bool Notebook::GetProperty(wxNotebook *p, JSContext *cx, JSObject *obj, int id,
bool Notebook::SetProperty(wxNotebook *p, JSContext *cx, JSObject *obj, int id, jsval *vp)
{
switch (id)
{
}
return true;
}
@ -101,6 +98,8 @@ struct Wrapper_wxNotebook : public wxNotebook
~Wrapper_wxNotebook()
{
wxList* d = GetDynamicEventTable();
if (d)
{
for (wxList::iterator it = d->begin(), end = d->end(); it != end; ++it)
{
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)*it;
@ -109,6 +108,7 @@ struct Wrapper_wxNotebook : public wxNotebook
}
d->Clear();
}
}
};
wxNotebook* Notebook::Construct(JSContext *cx,

View File

@ -275,7 +275,7 @@ JSBool RadioBox::create(JSContext *cx,
if ( argc > 9 )
argc = 9;
int style = 0;
int style = wxRA_SPECIFY_COLS;
int max = 0;
StringsPtr items;
const wxSize *size = &wxDefaultSize;

View File

@ -7,8 +7,6 @@
#include "../../common/main.h"
#include "../../common/apiwrap.h"
#include <wx/notebook.h>
#include "jsevent.h"
#include "../misc/size.h"
#include "notebookevt.h"

View File

@ -1,7 +1,7 @@
#ifndef _WXJSNotebookEvent_H
#define _WXJSNotebookEvent_H
class wxNotebookEvent;
#include <wx/notebook.h>
namespace wxjs
{

View File

@ -7,8 +7,6 @@
#include "../../common/main.h"
#include "../../common/apiwrap.h"
#include <wx/spinctrl.h>
#include "jsevent.h"
#include "../misc/size.h"
#include "spinevt.h"

View File

@ -1,7 +1,7 @@
#ifndef _WXJSSpinEvent_H
#define _WXJSSpinEvent_H
class wxSpinEvent;
#include <wx/spinctrl.h>
namespace wxjs
{

View File

@ -20,11 +20,23 @@
// Precompiled headers:
#ifdef USING_PCH
#define WX_PRECOMP
#include "common/main.h"
#include "wx/wxprec.h"
# define WX_PRECOMP
# include "common/main.h"
# include "wx/wxprec.h"
#endif
/*
// DISABLED: because normally this DLL gets unloaded before the leak reports, which means the
// __FILE__ strings are no longer in valid memory, which breaks everything.
#if defined(_MSC_VER) && !defined(NDEBUG)
// Include some STL headers that don't like 'new' being redefined
# include <map>
// then redefine 'new'
# define _CRTDBG_MAP_ALLOC
# include <crtdbg.h>
# define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
*/
#endif // INCLUDED_STDAFX