about summary refs log tree commit diff
path: root/src/game/editor
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/editor')
-rw-r--r--src/game/editor/ed_editor.h154
-rw-r--r--src/game/editor/ed_io.cpp130
-rw-r--r--src/game/editor/ed_layer_quads.cpp40
-rw-r--r--src/game/editor/ed_layer_tiles.cpp64
-rw-r--r--src/game/editor/ed_popups.cpp94
5 files changed, 241 insertions, 241 deletions
diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h
index 9d220bd6..aab757e1 100644
--- a/src/game/editor/ed_editor.h
+++ b/src/game/editor/ed_editor.h
@@ -30,7 +30,7 @@ enum
 {
 	MODE_LAYERS=0,
 	MODE_IMAGES,
-	
+
 	DIALOG_NONE=0,
 	DIALOG_FILE,
 };
@@ -48,7 +48,7 @@ public:
 	array<CEnvPoint> m_lPoints;
 	char m_aName[32];
 	float m_Bottom, m_Top;
-	
+
 	CEnvelope(int Chan)
 	{
 		m_Channels = Chan;
@@ -56,7 +56,7 @@ public:
 		m_Bottom = 0;
 		m_Top = 0;
 	}
-	
+
 	void Resort()
 	{
 		sort(m_lPoints.all());
@@ -80,13 +80,13 @@ public:
 			}
 		}
 	}
-	
+
 	int Eval(float Time, float *pResult)
 	{
 		CRenderTools::RenderEvalEnvelope(m_lPoints.base_ptr(), m_lPoints.size(), m_Channels, Time, pResult);
 		return m_Channels;
 	}
-	
+
 	void AddPoint(int Time, int v0, int v1=0, int v2=0, int v3=0)
 	{
 		CEnvPoint p;
@@ -99,7 +99,7 @@ public:
 		m_lPoints.add(p);
 		Resort();
 	}
-	
+
 	float EndTime()
 	{
 		if(m_lPoints.size())
@@ -130,12 +130,12 @@ public:
 		m_Flags = 0;
 		m_pEditor = 0;
 	}
-	
+
 	virtual ~CLayer()
 	{
 	}
-	
-	
+
+
 	virtual void BrushSelecting(CUIRect Rect) {}
 	virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) { return 0; }
 	virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) {}
@@ -144,15 +144,15 @@ public:
 	virtual void BrushFlipX() {}
 	virtual void BrushFlipY() {}
 	virtual void BrushRotate(float Amount) {}
-	
+
 	virtual void Render() {}
 	virtual int RenderProperties(CUIRect *pToolbox) { return 0; }
-	
+
 	virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc) {}
 	virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc) {}
-	
+
 	virtual void GetSize(float *w, float *h) { *w = 0; *h = 0;}
-	
+
 	const char *m_pTypeName;
 	int m_Type;
 	int m_Flags;
@@ -166,49 +166,49 @@ class CLayerGroup
 {
 public:
 	class CEditorMap *m_pMap;
-	
+
 	array<CLayer*> m_lLayers;
-	
+
 	int m_OffsetX;
 	int m_OffsetY;
 
 	int m_ParallaxX;
 	int m_ParallaxY;
-	
+
 	int m_UseClipping;
 	int m_ClipX;
 	int m_ClipY;
 	int m_ClipW;
 	int m_ClipH;
-	
+
 	const char *m_pName;
 	bool m_GameGroup;
 	bool m_Visible;
 	bool m_SaveToMap;
-	
+
 	CLayerGroup();
 	~CLayerGroup();
-	
+
 	void Convert(CUIRect *pRect);
 	void Render();
 	void MapScreen();
 	void Mapping(float *pPoints);
 
 	void GetSize(float *w, float *h);
-	
+
 	void DeleteLayer(int Index);
 	int SwapLayers(int Index0, int Index1);
-	
-	bool IsEmpty() const 
+
+	bool IsEmpty() const
 	{
 		return m_lLayers.size() == 0;
 	}
-	
-	void Clear() 
-	{ 
+
+	void Clear()
+	{
 		m_lLayers.delete_all();
 	}
-	
+
 	void AddLayer(CLayer *l);
 
 	void ModifyImageIndex(INDEX_MODIFY_FUNC Func)
@@ -216,7 +216,7 @@ public:
 		for(int i = 0; i < m_lLayers.size(); i++)
 			m_lLayers[i]->ModifyImageIndex(Func);
 	}
-	
+
 	void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
 	{
 		for(int i = 0; i < m_lLayers.size(); i++)
@@ -228,7 +228,7 @@ class CEditorImage : public CImageInfo
 {
 public:
 	CEditor *m_pEditor;
-	
+
 	CEditorImage(CEditor *pEditor)
 	{
 		m_pEditor = pEditor;
@@ -240,11 +240,11 @@ public:
 		m_pData = 0;
 		m_Format = 0;
 	}
-	
+
 	~CEditorImage();
-	
+
 	void AnalyseTileFlags();
-	
+
 	int m_TexID;
 	int m_External;
 	char m_aName[128];
@@ -267,10 +267,10 @@ public:
 	array<CLayerGroup*> m_lGroups;
 	array<CEditorImage*> m_lImages;
 	array<CEnvelope*> m_lEnvelopes;
-	
+
 	class CLayerGame *m_pGameLayer;
 	CLayerGroup *m_pGameGroup;
-	
+
 	CEnvelope *NewEnvelope(int Channels)
 	{
 		m_Modified = true;
@@ -280,7 +280,7 @@ public:
 	}
 
 	void DeleteEnvelope(int Index);
-	
+
 	CLayerGroup *NewGroup()
 	{
 		m_Modified = true;
@@ -289,7 +289,7 @@ public:
 		m_lGroups.add(g);
 		return g;
 	}
-	
+
 	int SwapGroups(int Index0, int Index1)
 	{
 		if(Index0 < 0 || Index0 >= m_lGroups.size()) return Index0;
@@ -299,7 +299,7 @@ public:
 		swap(m_lGroups[Index0], m_lGroups[Index1]);
 		return Index1;
 	}
-	
+
 	void DeleteGroup(int Index)
 	{
 		if(Index < 0 || Index >= m_lGroups.size()) return;
@@ -307,25 +307,25 @@ public:
 		delete m_lGroups[Index];
 		m_lGroups.remove_index(Index);
 	}
-	
+
 	void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc)
 	{
 		m_Modified = true;
 		for(int i = 0; i < m_lGroups.size(); i++)
 			m_lGroups[i]->ModifyImageIndex(pfnFunc);
 	}
-	
+
 	void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc)
 	{
 		m_Modified = true;
 		for(int i = 0; i < m_lGroups.size(); i++)
 			m_lGroups[i]->ModifyEnvelopeIndex(pfnFunc);
 	}
-	
+
 	void Clean();
 	void CreateDefault(int EntitiesTexture);
 
-	// io	
+	// io
 	int Save(class IStorage *pStorage, const char *pFilename);
 	int Load(class IStorage *pStorage, const char *pFilename, int StorageType);
 };
@@ -383,17 +383,17 @@ public:
 	virtual void BrushFlipX();
 	virtual void BrushFlipY();
 	virtual void BrushRotate(float Amount);
-	
+
 	virtual void ShowInfo();
 	virtual int RenderProperties(CUIRect *pToolbox);
 
 	virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc);
 	virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc);
-	
+
 	void PrepareForSave();
 
-	void GetSize(float *w, float *h) { *w = m_Width*32.0f;  *h = m_Height*32.0f; }
-	
+	void GetSize(float *w, float *h) { *w = m_Width*32.0f; *h = m_Height*32.0f; }
+
 	int m_TexID;
 	int m_Game;
 	int m_Image;
@@ -418,14 +418,14 @@ public:
 	virtual void BrushFlipX();
 	virtual void BrushFlipY();
 	virtual void BrushRotate(float Amount);
-	
+
 	virtual int RenderProperties(CUIRect *pToolbox);
 
 	virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc);
 	virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc);
-	
+
 	void GetSize(float *w, float *h);
-	
+
 	int m_Image;
 	array<CQuad> m_lQuads;
 };
@@ -475,7 +475,7 @@ public:
 		m_ValidSaveFilename = false;
 
 		m_PopupEventActivated = false;
-		
+
 		m_FileDialogStorageType = 0;
 		m_pFileDialogTitle = 0;
 		m_pFileDialogButtonText = 0;
@@ -495,7 +495,7 @@ public:
 		m_WorldOffsetY = 0;
 		m_EditorOffsetX = 0.0f;
 		m_EditorOffsetY = 0.0f;
-		
+
 		m_WorldZoom = 1.0f;
 		m_ZoomLevel = 200;
 		m_LockMouse = false;
@@ -504,36 +504,36 @@ public:
 		m_MouseDeltaY = 0;
 		m_MouseDeltaWx = 0;
 		m_MouseDeltaWy = 0;
-		
+
 		m_GuiActive = true;
 		m_ProofBorders = false;
-		
+
 		m_ShowTileInfo = false;
 		m_ShowDetail = true;
 		m_Animate = false;
 		m_AnimateStart = 0;
 		m_AnimateTime = 0;
 		m_AnimateSpeed = 1;
-		
+
 		m_ShowEnvelopeEditor = 0;
-		
+
 		ms_CheckerTexture = 0;
 		ms_BackgroundTexture = 0;
 		ms_CursorTexture = 0;
 		ms_EntitiesTexture = 0;
-		
+
 		ms_pUiGotContext = 0;
 	}
-	
+
 	virtual void Init();
 	virtual void UpdateAndRender();
 	virtual bool HasUnsavedData() { return m_Map.m_Modified; }
-	
+
 	void FilelistPopulate(int StorageType);
 	void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText,
 		const char *pBasepath, const char *pDefaultName,
 		void (*pfnFunc)(const char *pFilename, int StorageType, void *pUser), void *pUser);
-	
+
 	void Reset(bool CreateDefault=true);
 	int Save(const char *pFilename);
 	int Load(const char *pFilename, int StorageType);
@@ -544,9 +544,9 @@ public:
 	CLayer *GetSelectedLayerType(int Index, int Type);
 	CLayer *GetSelectedLayer(int Index);
 	CLayerGroup *GetSelectedGroup();
-	
+
 	int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal);
-	
+
 	int m_Mode;
 	int m_Dialog;
 	const char *m_pTooltip;
@@ -573,7 +573,7 @@ public:
 
 		MAX_PATH_LENGTH = 512
 	};
-	
+
 	int m_FileDialogStorageType;
 	const char *m_pFileDialogTitle;
 	const char *m_pFileDialogButtonText;
@@ -597,7 +597,7 @@ public:
 		bool m_IsDir;
 		bool m_IsLink;
 		int m_StorageType;
-		
+
 		bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false :
 														m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false :
 														str_comp_filenames(m_aFilename, Other.m_aFilename) < 0; }
@@ -621,36 +621,36 @@ public:
 	float m_MouseDeltaY;
 	float m_MouseDeltaWx;
 	float m_MouseDeltaWy;
-	
+
 	bool m_ShowTileInfo;
 	bool m_ShowDetail;
 	bool m_Animate;
 	int64 m_AnimateStart;
 	float m_AnimateTime;
 	float m_AnimateSpeed;
-	
+
 	int m_ShowEnvelopeEditor;
-	
+
 	int m_SelectedLayer;
 	int m_SelectedGroup;
 	int m_SelectedQuad;
 	int m_SelectedPoints;
 	int m_SelectedEnvelope;
 	int m_SelectedImage;
-	
+
 	static int ms_CheckerTexture;
 	static int ms_BackgroundTexture;
 	static int ms_CursorTexture;
 	static int ms_EntitiesTexture;
-	
+
 	CLayerGroup m_Brush;
 	CLayerTiles m_TilesetPicker;
-	
+
 	static const void *ms_pUiGotContext;
-	
+
 	CEditorMap m_Map;
-	
-    void DoMapBorder();
+
+	void DoMapBorder();
 	int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
 	int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
 
@@ -660,17 +660,17 @@ public:
 	int DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
 
 	int DoButton_File(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
-	
+
 	int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
 	int DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags=0, const char *pToolTip=0);
-	
+
 	int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, bool Hidden=false);
 
 	void RenderBackground(CUIRect View, int Texture, float Size, float Brightness);
 
 	void UiInvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra=0);
 	void UiDoPopupMenu();
-	
+
 	int UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip);
 
 	static int PopupGroup(CEditor *pEditor, CUIRect View);
@@ -693,7 +693,7 @@ public:
 
 	void PopupSelectGametileOpInvoke(float x, float y);
 	int PopupSelectGameTileOpResult();
-	
+
 	vec4 ButtonColorMul(const void *pID);
 
 	void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
@@ -702,16 +702,16 @@ public:
 	void DoQuad(CQuad *pQuad, int Index);
 	float UiDoScrollbarV(const void *pID, const CUIRect *pRect, float Current);
 	vec4 GetButtonColor(const void *pID, int Checked);
-	
+
 	static void ReplaceImage(const char *pFilename, int StorageType, void *pUser);
 	static void AddImage(const char *pFilename, int StorageType, void *pUser);
-	
+
 	void RenderImages(CUIRect Toolbox, CUIRect Toolbar, CUIRect View);
 	void RenderLayers(CUIRect Toolbox, CUIRect Toolbar, CUIRect View);
 	void RenderModebar(CUIRect View);
 	void RenderStatusbar(CUIRect View);
 	void RenderEnvelopeEditor(CUIRect View);
-	
+
 	void RenderMenubar(CUIRect Menubar);
 	void RenderFileDialog();
 
diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp
index 4dd71245..a5ead97a 100644
--- a/src/game/editor/ed_io.cpp
+++ b/src/game/editor/ed_io.cpp
@@ -67,7 +67,7 @@ void editor_load_old(DATAFILE *df, MAP *map)
 		MAPRES_FLAGSTAND_RED=5,
 		MAPRES_FLAGSTAND_BLUE=6,
 		MAPRES_ENTS_END,
-		
+
 		ITEM_NULL=0,
 		ITEM_WEAPON_GUN=0x00010001,
 		ITEM_WEAPON_SHOTGUN=0x00010002,
@@ -78,7 +78,7 @@ void editor_load_old(DATAFILE *df, MAP *map)
 		ITEM_ARMOR=0x00030001,
 		ITEM_NINJA=0x00040001,
 	};
-	
+
 	enum
 	{
 		MAPRES_REGISTERED=0x8000,
@@ -97,9 +97,9 @@ void editor_load_old(DATAFILE *df, MAP *map)
 		for(int t = 0; t < num; t++)
 		{
 			mapres_tilemap *tmap = (mapres_tilemap *)datafile_get_item(df, start+t,0,0);
-			
+
 			CLayerTiles *l = new CLayerTiles(tmap->width, tmap->height);
-			
+
 			if(tmap->main)
 			{
 				// move game layer to correct position
@@ -108,7 +108,7 @@ void editor_load_old(DATAFILE *df, MAP *map)
 					if(map->groups[0]->layers[i] == pEditor->map.game_layer)
 						map->groups[0]->swap_layers(i, i+1);
 				}
-				
+
 				game_width = tmap->width;
 				game_height = tmap->height;
 			}
@@ -119,18 +119,18 @@ void editor_load_old(DATAFILE *df, MAP *map)
 			// process the data
 			unsigned char *src_data = (unsigned char *)datafile_get_data(df, tmap->data);
 			CTile *dst_data = l->tiles;
-			
+
 			for(int y = 0; y < tmap->height; y++)
 				for(int x = 0; x < tmap->width; x++, dst_data++, src_data+=2)
 				{
 					dst_data->index = src_data[0];
 					dst_data->flags = src_data[1];
 				}
-				
+
 			l->image = tmap->image;
 		}
 	}
-	
+
 	// load images
 	{
 		int start, count;
@@ -144,18 +144,18 @@ void editor_load_old(DATAFILE *df, MAP *map)
 			img->width = imgres->width;
 			img->height = imgres->height;
 			img->format = CImageInfo::FORMAT_RGBA;
-			
+
 			// copy image data
 			img->data = mem_alloc(img->width*img->height*4, 1);
 			mem_copy(img->data, data, img->width*img->height*4);
 			img->tex_id = Graphics()->LoadTextureRaw(img->width, img->height, img->format, img->data, CImageInfo::FORMAT_AUTO, 0);
 			map->images.add(img);
-			
+
 			// unload image
 			datafile_unload_data(df, imgres->image_data);
 		}
 	}
-	
+
 	// load entities
 	{
 		CLayerGame *g = map->game_layer;
@@ -173,7 +173,7 @@ void editor_load_old(DATAFILE *df, MAP *map)
 				int x = e->x/32;
 				int y = e->y/32;
 				int id = -1;
-					
+
 				if(t == MAPRES_SPAWNPOINT) id = ENTITY_SPAWN;
 				else if(t == MAPRES_SPAWNPOINT_RED) id = ENTITY_SPAWN_RED;
 				else if(t == MAPRES_SPAWNPOINT_BLUE) id = ENTITY_SPAWN_BLUE;
@@ -187,7 +187,7 @@ void editor_load_old(DATAFILE *df, MAP *map)
 					else if(e->data[0] == ITEM_ARMOR) id = ENTITY_ARMOR_1;
 					else if(e->data[0] == ITEM_HEALTH) id = ENTITY_HEALTH_1;
 				}
-						
+
 				if(id > 0 && x >= 0 && x < g->width && y >= 0 && y < g->height)
 					g->tiles[y*g->width+x].index = id+ENTITY_OFFSET;
 			}
@@ -212,7 +212,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 		m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf);
 		return 0;
 	}
-		
+
 	// save version
 	{
 		CMapItemVersion Item;
@@ -224,14 +224,14 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 	for(int i = 0; i < m_lImages.size(); i++)
 	{
 		CEditorImage *pImg = m_lImages[i];
-		
+
 		// analyse the image for when saving (should be done when we load the image)
 		// TODO!
 		pImg->AnalyseTileFlags();
-		
+
 		CMapItemImage Item;
 		Item.m_Version = 1;
-		
+
 		Item.m_Width = pImg->m_Width;
 		Item.m_Height = pImg->m_Height;
 		Item.m_External = pImg->m_External;
@@ -242,7 +242,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 			Item.m_ImageData = df.AddData(Item.m_Width*Item.m_Height*4, pImg->m_pData);
 		df.AddItem(MAPITEMTYPE_IMAGE, i, sizeof(Item), &Item);
 	}
-	
+
 	// save layers
 	int LayerCount = 0, GroupCount = 0;
 	for(int g = 0; g < m_lGroups.size(); g++)
@@ -253,7 +253,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 
 		CMapItemGroup GItem;
 		GItem.m_Version = CMapItemGroup::CURRENT_VERSION;
-		
+
 		GItem.m_ParallaxX = pGroup->m_ParallaxX;
 		GItem.m_ParallaxY = pGroup->m_ParallaxY;
 		GItem.m_OffsetX = pGroup->m_OffsetX;
@@ -265,7 +265,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 		GItem.m_ClipH = pGroup->m_ClipH;
 		GItem.m_StartLayer = LayerCount;
 		GItem.m_NumLayers = 0;
-		
+
 		for(int l = 0; l < pGroup->m_lLayers.size(); l++)
 		{
 			if(!pGroup->m_lLayers[l]->m_SaveToMap)
@@ -276,27 +276,27 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 				m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer");
 				CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l];
 				pLayer->PrepareForSave();
-				
+
 				CMapItemLayerTilemap Item;
 				Item.m_Version = 2;
-				
+
 				Item.m_Layer.m_Flags = pLayer->m_Flags;
 				Item.m_Layer.m_Type = pLayer->m_Type;
-				
+
 				Item.m_Color.r = pLayer->m_Color.r;
 				Item.m_Color.g = pLayer->m_Color.g;
 				Item.m_Color.b = pLayer->m_Color.b;
 				Item.m_Color.a = pLayer->m_Color.a;
 				Item.m_ColorEnv = -1; // not in use right now
 				Item.m_ColorEnvOffset = 0;
-				
+
 				Item.m_Width = pLayer->m_Width;
 				Item.m_Height = pLayer->m_Height;
 				Item.m_Flags = pLayer->m_Game;
 				Item.m_Image = pLayer->m_Image;
 				Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pLayer->m_pTiles);
 				df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
-				
+
 				GItem.m_NumLayers++;
 				LayerCount++;
 			}
@@ -308,15 +308,15 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 				{
 					CMapItemLayerQuads Item;
 					Item.m_Version = 1;
-					Item.m_Layer.m_Flags =  pLayer->m_Flags;
+					Item.m_Layer.m_Flags = pLayer->m_Flags;
 					Item.m_Layer.m_Type = pLayer->m_Type;
 					Item.m_Image = pLayer->m_Image;
-					
+
 					// add the data
 					Item.m_NumQuads = pLayer->m_lQuads.size();
 					Item.m_Data = df.AddDataSwapped(pLayer->m_lQuads.size()*sizeof(CQuad), pLayer->m_lQuads.base_ptr());
 					df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
-					
+
 					// clean up
 					//mem_free(quads);
 
@@ -325,10 +325,10 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 				}
 			}
 		}
-		
+
 		df.AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem);
 	}
-	
+
 	// save envelopes
 	int PointCount = 0;
 	for(int e = 0; e < m_lEnvelopes.size(); e++)
@@ -339,16 +339,16 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 		Item.m_StartPoint = PointCount;
 		Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size();
 		StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName);
-		
+
 		df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item);
 		PointCount += Item.m_NumPoints;
 	}
-	
+
 	// save points
 	int TotalSize = sizeof(CEnvPoint) * PointCount;
 	CEnvPoint *pPoints = (CEnvPoint *)mem_alloc(TotalSize, 1);
 	PointCount = 0;
-	
+
 	for(int e = 0; e < m_lEnvelopes.size(); e++)
 	{
 		int Count = m_lEnvelopes[e]->m_lPoints.size();
@@ -357,11 +357,11 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 	}
 
 	df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints);
-	
+
 	// finish the data file
 	df.Finish();
 	m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done");
-	
+
 	// send rcon.. if we can
 	if(m_pEditor->Client()->RconAuthed())
 	{
@@ -372,7 +372,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
 		if(!str_comp(aMapName, CurrentServerInfo.m_aMap))
 			m_pEditor->Client()->Rcon("reload");
 	}
-	
+
 	return 1;
 }
 
@@ -388,7 +388,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 	//DATAFILE *df = datafile_load(filename);
 	if(!DataFile.Open(pStorage, pFileName, StorageType))
 		return 0;
-		
+
 	Clean();
 
 	// check version
@@ -404,7 +404,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 	else if(pItem->m_Version == 1)
 	{
 		//editor.reset(false);
-		
+
 		// load images
 		{
 			int Start, Num;
@@ -414,7 +414,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 				CMapItemImage *pItem = (CMapItemImage *)DataFile.GetItem(Start+i, 0, 0);
 				char *pName = (char *)DataFile.GetData(pItem->m_ImageName);
 
-				// copy base info				
+				// copy base info
 				CEditorImage *pImg = new CEditorImage(m_pEditor);
 				pImg->m_External = pItem->m_External;
 
@@ -422,7 +422,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 				{
 					char aBuf[256];
 					str_format(aBuf, sizeof(aBuf),"mapres/%s.png", pName);
-					
+
 					// load external
 					CEditorImage ImgInfo(m_pEditor);
 					if(m_pEditor->Graphics()->LoadPNG(&ImgInfo, aBuf, IStorage::TYPE_ALL))
@@ -437,7 +437,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 					pImg->m_Width = pItem->m_Width;
 					pImg->m_Height = pItem->m_Height;
 					pImg->m_Format = CImageInfo::FORMAT_RGBA;
-					
+
 					// copy image data
 					void *pData = DataFile.GetData(pItem->m_ImageData);
 					pImg->m_pData = mem_alloc(pImg->m_Width*pImg->m_Height*4, 1);
@@ -450,33 +450,33 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 					str_copy(pImg->m_aName, pName, 128);
 
 				m_lImages.add(pImg);
-				
+
 				// unload image
 				DataFile.UnloadData(pItem->m_ImageData);
 				DataFile.UnloadData(pItem->m_ImageName);
 			}
 		}
-		
+
 		// load groups
 		{
 			int LayersStart, LayersNum;
 			DataFile.GetType(MAPITEMTYPE_LAYER, &LayersStart, &LayersNum);
-			
+
 			int Start, Num;
 			DataFile.GetType(MAPITEMTYPE_GROUP, &Start, &Num);
 			for(int g = 0; g < Num; g++)
 			{
 				CMapItemGroup *pGItem = (CMapItemGroup *)DataFile.GetItem(Start+g, 0, 0);
-				
+
 				if(pGItem->m_Version < 1 || pGItem->m_Version > CMapItemGroup::CURRENT_VERSION)
 					continue;
-				
+
 				CLayerGroup *pGroup = NewGroup();
 				pGroup->m_ParallaxX = pGItem->m_ParallaxX;
 				pGroup->m_ParallaxY = pGItem->m_ParallaxY;
 				pGroup->m_OffsetX = pGItem->m_OffsetX;
 				pGroup->m_OffsetY = pGItem->m_OffsetY;
-				
+
 				if(pGItem->m_Version >= 2)
 				{
 					pGroup->m_UseClipping = pGItem->m_UseClipping;
@@ -485,19 +485,19 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 					pGroup->m_ClipW = pGItem->m_ClipW;
 					pGroup->m_ClipH = pGItem->m_ClipH;
 				}
-				
+
 				for(int l = 0; l < pGItem->m_NumLayers; l++)
 				{
 					CLayer *pLayer = 0;
 					CMapItemLayer *pLayerItem = (CMapItemLayer *)DataFile.GetItem(LayersStart+pGItem->m_StartLayer+l, 0, 0);
 					if(!pLayerItem)
 						continue;
-						
+
 					if(pLayerItem->m_Type == LAYERTYPE_TILES)
 					{
 						CMapItemLayerTilemap *pTilemapItem = (CMapItemLayerTilemap *)pLayerItem;
 						CLayerTiles *pTiles = 0;
-						
+
 						if(pTilemapItem->m_Flags&1)
 						{
 							pTiles = new CLayerGame(pTilemapItem->m_Width, pTilemapItem->m_Height);
@@ -515,14 +515,14 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 						}
 
 						pLayer = pTiles;
-						
+
 						pGroup->AddLayer(pTiles);
 						void *pData = DataFile.GetData(pTilemapItem->m_Data);
 						pTiles->m_Image = pTilemapItem->m_Image;
 						pTiles->m_Game = pTilemapItem->m_Flags&1;
-						
+
 						mem_copy(pTiles->m_pTiles, pData, pTiles->m_Width*pTiles->m_Height*sizeof(CTile));
-						
+
 						if(pTiles->m_Game && pTilemapItem->m_Version == MakeVersion(1, *pTilemapItem))
 						{
 							for(int i = 0; i < pTiles->m_Width*pTiles->m_Height; i++)
@@ -531,7 +531,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 									pTiles->m_pTiles[i].m_Index += ENTITY_OFFSET;
 							}
 						}
-						
+
 						DataFile.UnloadData(pTilemapItem->m_Data);
 					}
 					else if(pLayerItem->m_Type == LAYERTYPE_QUADS)
@@ -549,24 +549,24 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 						mem_copy(pQuads->m_lQuads.base_ptr(), pData, sizeof(CQuad)*pQuadsItem->m_NumQuads);
 						DataFile.UnloadData(pQuadsItem->m_Data);
 					}
-					
+
 					if(pLayer)
 						pLayer->m_Flags = pLayerItem->m_Flags;
 				}
 			}
 		}
-		
+
 		// load envelopes
 		{
 			CEnvPoint *pPoints = 0;
-			
+
 			{
 				int Start, Num;
 				DataFile.GetType(MAPITEMTYPE_ENVPOINTS, &Start, &Num);
 				if(Num)
 					pPoints = (CEnvPoint *)DataFile.GetItem(Start, 0, 0);
 			}
-			
+
 			int Start, Num;
 			DataFile.GetType(MAPITEMTYPE_ENVELOPE, &Start, &Num);
 			for(int e = 0; e < Num; e++)
@@ -581,7 +581,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
 			}
 		}
 	}
-	
+
 	return 1;
 }
 
@@ -602,25 +602,25 @@ int CEditor::Append(const char *pFileName, int StorageType)
 	if(!Err)
 		return Err;
 
-	// modify indecies	
+	// modify indecies
 	gs_ModifyAddAmount = m_Map.m_lImages.size();
 	NewMap.ModifyImageIndex(ModifyAdd);
-	
+
 	gs_ModifyAddAmount = m_Map.m_lEnvelopes.size();
 	NewMap.ModifyEnvelopeIndex(ModifyAdd);
-	
+
 	// transfer images
 	for(int i = 0; i < NewMap.m_lImages.size(); i++)
 		m_Map.m_lImages.add(NewMap.m_lImages[i]);
 	NewMap.m_lImages.clear();
-	
+
 	// transfer envelopes
 	for(int i = 0; i < NewMap.m_lEnvelopes.size(); i++)
 		m_Map.m_lEnvelopes.add(NewMap.m_lEnvelopes[i]);
 	NewMap.m_lEnvelopes.clear();
 
 	// transfer groups
-	
+
 	for(int i = 0; i < NewMap.m_lGroups.size(); i++)
 	{
 		if(NewMap.m_lGroups[i] == NewMap.m_pGameGroup)
@@ -632,7 +632,7 @@ int CEditor::Append(const char *pFileName, int StorageType)
 		}
 	}
 	NewMap.m_lGroups.clear();
-	
+
 	// all done \o/
 	return 0;
 }
diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp
index 4f2e468c..680a54cd 100644
--- a/src/game/editor/ed_layer_quads.cpp
+++ b/src/game/editor/ed_layer_quads.cpp
@@ -32,7 +32,7 @@ static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUse
 		pChannels[3] = 0;
 		return;
 	}
-		
+
 	CEnvelope *e = pEditor->m_Map.m_lEnvelopes[Env];
 	float t = pEditor->m_AnimateTime+TimeOffset;
 	t *= pEditor->m_AnimateSpeed;
@@ -44,7 +44,7 @@ void CLayerQuads::Render()
 	Graphics()->TextureSet(-1);
 	if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
 		Graphics()->TextureSet(m_pEditor->m_Map.m_lImages[m_Image]->m_TexID);
-		
+
 	m_pEditor->RenderTools()->RenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, m_pEditor);
 }
 
@@ -70,26 +70,26 @@ CQuad *CLayerQuads::NewQuad()
 
 	q->m_aPoints[4].x = x+32; // pivot
 	q->m_aPoints[4].y = y+32;
-	
+
 	for(int i = 0; i < 5; i++)
 	{
 		q->m_aPoints[i].x <<= 10;
 		q->m_aPoints[i].y <<= 10;
 	}
-	
+
 
 	q->m_aTexcoords[0].x = 0;
 	q->m_aTexcoords[0].y = 0;
-	
+
 	q->m_aTexcoords[1].x = 1<<10;
 	q->m_aTexcoords[1].y = 0;
-	
+
 	q->m_aTexcoords[2].x = 0;
 	q->m_aTexcoords[2].y = 1<<10;
-	
+
 	q->m_aTexcoords[3].x = 1<<10;
 	q->m_aTexcoords[3].y = 1<<10;
-	
+
 	q->m_aColors[0].r = 255; q->m_aColors[0].g = 255; q->m_aColors[0].b = 255; q->m_aColors[0].a = 255;
 	q->m_aColors[1].r = 255; q->m_aColors[1].g = 255; q->m_aColors[1].b = 255; q->m_aColors[1].a = 255;
 	q->m_aColors[2].r = 255; q->m_aColors[2].g = 255; q->m_aColors[2].b = 255; q->m_aColors[2].a = 255;
@@ -119,29 +119,29 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
 	pGrabbed->m_pEditor = m_pEditor;
 	pGrabbed->m_Image = m_Image;
 	pBrush->AddLayer(pGrabbed);
-	
+
 	//dbg_msg("", "%f %f %f %f", rect.x, rect.y, rect.w, rect.h);
 	for(int i = 0; i < m_lQuads.size(); i++)
 	{
 		CQuad *q = &m_lQuads[i];
 		float px = fx2f(q->m_aPoints[4].x);
 		float py = fx2f(q->m_aPoints[4].y);
-		
+
 		if(px > Rect.x && px < Rect.x+Rect.w && py > Rect.y && py < Rect.y+Rect.h)
 		{
 			CQuad n;
 			n = *q;
-			
+
 			for(int p = 0; p < 5; p++)
 			{
 				n.m_aPoints[p].x -= f2fx(Rect.x);
 				n.m_aPoints[p].y -= f2fx(Rect.y);
 			}
-			
+
 			pGrabbed->m_lQuads.add(n);
 		}
 	}
-	
+
 	return pGrabbed->m_lQuads.size()?1:0;
 }
 
@@ -151,13 +151,13 @@ void CLayerQuads::BrushPlace(CLayer *pBrush, float wx, float wy)
 	for(int i = 0; i < l->m_lQuads.size(); i++)
 	{
 		CQuad n = l->m_lQuads[i];
-		
+
 		for(int p = 0; p < 5; p++)
 		{
 			n.m_aPoints[p].x += f2fx(wx);
 			n.m_aPoints[p].y += f2fx(wy);
 		}
-			
+
 		m_lQuads.add(n);
 	}
 	m_pEditor->m_Map.m_Modified = true;
@@ -189,7 +189,7 @@ void CLayerQuads::BrushRotate(float Amount)
 	for(int i = 0; i < m_lQuads.size(); i++)
 	{
 		CQuad *q = &m_lQuads[i];
-		
+
 		for(int p = 0; p < 5; p++)
 		{
 			vec2 Pos(fx2f(q->m_aPoints[p].x), fx2f(q->m_aPoints[p].y));
@@ -203,7 +203,7 @@ void CLayerQuads::BrushRotate(float Amount)
 void CLayerQuads::GetSize(float *w, float *h)
 {
 	*w = 0; *h = 0;
-	
+
 	for(int i = 0; i < m_lQuads.size(); i++)
 	{
 		for(int p = 0; p < 5; p++)
@@ -224,18 +224,18 @@ int CLayerQuads::RenderProperties(CUIRect *pToolBox)
 		PROP_IMAGE=0,
 		NUM_PROPS,
 	};
-	
+
 	CProperty aProps[] = {
 		{"Image", m_Image, PROPTYPE_IMAGE, -1, 0},
 		{0},
 	};
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
 	int Prop = m_pEditor->DoProperties(pToolBox, aProps, s_aIds, &NewVal);
 	if(Prop != -1)
 		m_pEditor->m_Map.m_Modified = true;
-	
+
 	if(Prop == PROP_IMAGE)
 	{
 		if(NewVal >= 0)
diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp
index dcbb0afe..d0c9041c 100644
--- a/src/game/editor/ed_layer_tiles.cpp
+++ b/src/game/editor/ed_layer_tiles.cpp
@@ -25,7 +25,7 @@ CLayerTiles::CLayerTiles(int w, int h)
 	m_Color.g = 255;
 	m_Color.b = 255;
 	m_Color.a = 255;
-	
+
 	m_pTiles = new CTile[m_Width*m_Height];
 	mem_zero(m_pTiles, m_Width*m_Height*sizeof(CTile));
 }
@@ -93,19 +93,19 @@ void CLayerTiles::Clamp(RECTi *pRect)
 		pRect->w += pRect->x;
 		pRect->x = 0;
 	}
-		
+
 	if(pRect->y < 0)
 	{
 		pRect->h += pRect->y;
 		pRect->y = 0;
 	}
-	
+
 	if(pRect->x+pRect->w > m_Width)
 		pRect->w = m_Width - pRect->x;
 
 	if(pRect->y+pRect->h > m_Height)
 		pRect->h = m_Height - pRect->y;
-		
+
 	if(pRect->h < 0)
 		pRect->h = 0;
 	if(pRect->w < 0)
@@ -131,10 +131,10 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
 	RECTi r;
 	Convert(Rect, &r);
 	Clamp(&r);
-	
+
 	if(!r.w || !r.h)
 		return 0;
-	
+
 	// create new layers
 	CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
 	pGrabbed->m_pEditor = m_pEditor;
@@ -142,12 +142,12 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
 	pGrabbed->m_Image = m_Image;
 	pGrabbed->m_Game = m_Game;
 	pBrush->AddLayer(pGrabbed);
-	
+
 	// copy the tiles
 	for(int y = 0; y < r.h; y++)
 		for(int x = 0; x < r.w; x++)
 			pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
-	
+
 	return 1;
 }
 
@@ -155,28 +155,28 @@ void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
 {
 	if(m_Readonly)
 		return;
-		
+
 	int sx = ConvertX(Rect.x);
 	int sy = ConvertY(Rect.y);
 	int w = ConvertX(Rect.w);
 	int h = ConvertY(Rect.h);
-	
+
 	CLayerTiles *pLt = static_cast<CLayerTiles*>(pBrush);
-	
+
 	for(int y = 0; y <= h; y++)
 	{
 		for(int x = 0; x <= w; x++)
 		{
 			int fx = x+sx;
 			int fy = y+sy;
-			
+
 			if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height)
 				continue;
-			
-			if(Empty)	
-                m_pTiles[fy*m_Width+fx].m_Index = 1;
-            else
-                m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
+
+			if(Empty)
+				m_pTiles[fy*m_Width+fx].m_Index = 1;
+			else
+				m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
 		}
 	}
 	m_pEditor->m_Map.m_Modified = true;
@@ -186,12 +186,12 @@ void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
 {
 	if(m_Readonly)
 		return;
-	
+
 	//
 	CLayerTiles *l = (CLayerTiles *)pBrush;
 	int sx = ConvertX(wx);
 	int sy = ConvertY(wy);
-	
+
 	for(int y = 0; y < l->m_Height; y++)
 		for(int x = 0; x < l->m_Width; x++)
 		{
@@ -199,7 +199,7 @@ void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
 			int fy = y+sy;
 			if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
 				continue;
-				
+
 			m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
 		}
 	m_pEditor->m_Map.m_Modified = true;
@@ -279,10 +279,10 @@ void CLayerTiles::Resize(int NewW, int NewH)
 	CTile *pNewData = new CTile[NewW*NewH];
 	mem_zero(pNewData, NewW*NewH*sizeof(CTile));
 
-	// copy old data	
+	// copy old data
 	for(int y = 0; y < min(NewH, m_Height); y++)
 		mem_copy(&pNewData[y*NewW], &m_pTiles[y*m_Width], min(m_Width, NewW)*sizeof(CTile));
-	
+
 	// replace old
 	delete [] m_pTiles;
 	m_pTiles = pNewData;
@@ -329,12 +329,12 @@ void CLayerTiles::ShowInfo()
 	float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
 	Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
 	Graphics()->TextureSet(m_pEditor->Client()->GetDebugFont());
-	
+
 	int StartY = max(0, (int)(ScreenY0/32.0f)-1);
 	int StartX = max(0, (int)(ScreenX0/32.0f)-1);
 	int EndY = min((int)(ScreenY1/32.0f)+1, m_Height);
 	int EndX = min((int)(ScreenX1/32.0f)+1, m_Width);
-	
+
 	for(int y = StartY; y < EndY; y++)
 		for(int x = StartX; x < EndX; x++)
 		{
@@ -359,7 +359,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 {
 	CUIRect Button;
 	pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
-	
+
 	bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty();
 	if(m_pEditor->m_Map.m_pGameLayer == this)
 		InGameGroup = false;
@@ -384,7 +384,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 			return 1;
 		}
 	}
-	
+
 	enum
 	{
 		PROP_WIDTH=0,
@@ -394,13 +394,13 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 		PROP_COLOR,
 		NUM_PROPS,
 	};
-	
+
 	int Color = 0;
 	Color |= m_Color.r<<24;
 	Color |= m_Color.g<<16;
 	Color |= m_Color.b<<8;
 	Color |= m_Color.a;
-	
+
 	CProperty aProps[] = {
 		{"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
 		{"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
@@ -409,19 +409,19 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 		{"Color", Color, PROPTYPE_COLOR, 0, 0},
 		{0},
 	};
-	
+
 	if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image and color properties if this is the game layer
 	{
 		aProps[3].m_pName = 0;
 		aProps[4].m_pName = 0;
 	}
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
 	int Prop = m_pEditor->DoProperties(pToolBox, aProps, s_aIds, &NewVal);
 	if(Prop != -1)
 		m_pEditor->m_Map.m_Modified = true;
-	
+
 	if(Prop == PROP_WIDTH && NewVal > 1)
 		Resize(NewVal, m_Height);
 	else if(Prop == PROP_HEIGHT && NewVal > 1)
@@ -445,7 +445,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
 		m_Color.b = (NewVal>>8)&0xff;
 		m_Color.a = NewVal&0xff;
 	}
-	
+
 	return 0;
 }
 
diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp
index 8f2c929a..f572e43c 100644
--- a/src/game/editor/ed_popups.cpp
+++ b/src/game/editor/ed_popups.cpp
@@ -44,7 +44,7 @@ void CEditor::UiDoPopupMenu()
 	{
 		bool Inside = UI()->MouseInside(&s_UiPopups[i].m_Rect);
 		UI()->SetHotItem(&s_UiPopups[i].m_pId);
-		
+
 		if(UI()->ActiveItem() == &s_UiPopups[i].m_pId)
 		{
 			if(!UI()->MouseButton(0))
@@ -59,20 +59,20 @@ void CEditor::UiDoPopupMenu()
 			if(UI()->MouseButton(0))
 				UI()->SetActiveItem(&s_UiPopups[i].m_pId);
 		}
-		
+
 		int Corners = CUI::CORNER_ALL;
 		if(s_UiPopups[i].m_IsMenu)
 			Corners = CUI::CORNER_R|CUI::CORNER_B;
-		
+
 		CUIRect r = s_UiPopups[i].m_Rect;
 		RenderTools()->DrawUIRect(&r, vec4(0.5f,0.5f,0.5f,0.75f), Corners, 3.0f);
 		r.Margin(1.0f, &r);
 		RenderTools()->DrawUIRect(&r, vec4(0,0,0,0.75f), Corners, 3.0f);
 		r.Margin(4.0f, &r);
-		
+
 		if(s_UiPopups[i].m_pfnFunc(this, r))
 			g_UiNumPopups--;
-			
+
 		if(Input()->KeyDown(KEY_ESCAPE))
 			g_UiNumPopups--;
 	}
@@ -85,7 +85,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
 	CUIRect Button;
 	View.HSplitBottom(12.0f, &View, &Button);
 	static int s_DeleteButton = 0;
-	
+
 	// don't allow deletion of game group
 	if(pEditor->m_Map.m_pGameGroup != pEditor->GetSelectedGroup())
 	{
@@ -162,7 +162,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
 		pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
 		return 1;
 	}
-	
+
 	enum
 	{
 		PROP_ORDER=0,
@@ -177,7 +177,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
 		PROP_CLIP_H,
 		NUM_PROPS,
 	};
-	
+
 	CProperty aProps[] = {
 		{"Order", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size()-1},
 		{"Pos X", -pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_OffsetX, PROPTYPE_INT_SCROLL, -1000000, 1000000},
@@ -192,21 +192,21 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
 		{"Clip H", pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_ClipH, PROPTYPE_INT_SCROLL, -1000000, 1000000},
 		{0},
 	};
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
-	
+
 	// cut the properties that isn't needed
 	if(pEditor->GetSelectedGroup()->m_GameGroup)
 		aProps[PROP_POS_X].m_pName = 0;
-		
+
 	int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
 	if(Prop != -1)
 		pEditor->m_Map.m_Modified = true;
 
 	if(Prop == PROP_ORDER)
 		pEditor->m_SelectedGroup = pEditor->m_Map.SwapGroups(pEditor->m_SelectedGroup, NewVal);
-		
+
 	// these can not be changed on the game group
 	if(!pEditor->GetSelectedGroup()->m_GameGroup)
 	{
@@ -220,7 +220,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
 		else if(Prop == PROP_CLIP_W) pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_ClipW = NewVal;
 		else if(Prop == PROP_CLIP_H) pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_ClipH = NewVal;
 	}
-	
+
 	return 0;
 }
 
@@ -230,7 +230,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
 	CUIRect Button;
 	View.HSplitBottom(12.0f, &View, &Button);
 	static int s_DeleteButton = 0;
-	
+
 	// don't allow deletion of game layer
 	if(pEditor->m_Map.m_pGameLayer != pEditor->GetSelectedLayer(0) &&
 		pEditor->DoButton_Editor(&s_DeleteButton, "Delete layer", 0, &Button, 0, "Deletes the layer"))
@@ -240,10 +240,10 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
 	}
 
 	View.HSplitBottom(10.0f, &View, 0);
-	
+
 	CLayerGroup *pCurrentGroup = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup];
 	CLayer *pCurrentLayer = pEditor->GetSelectedLayer(0);
-	
+
 	enum
 	{
 		PROP_GROUP=0,
@@ -251,7 +251,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
 		PROP_HQ,
 		NUM_PROPS,
 	};
-	
+
 	CProperty aProps[] = {
 		{"Group", pEditor->m_SelectedGroup, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lGroups.size()-1},
 		{"Order", pEditor->m_SelectedLayer, PROPTYPE_INT_STEP, 0, pCurrentGroup->m_lLayers.size()},
@@ -264,13 +264,13 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
 		aProps[0].m_Type = PROPTYPE_NULL;
 		aProps[2].m_Type = PROPTYPE_NULL;
 	}
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
 	int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
 	if(Prop != -1)
 		pEditor->m_Map.m_Modified = true;
-	
+
 	if(Prop == PROP_ORDER)
 		pEditor->m_SelectedLayer = pCurrentGroup->SwapLayers(pEditor->m_SelectedLayer, NewVal);
 	else if(Prop == PROP_GROUP && pCurrentLayer->m_Type != LAYERTYPE_GAME)
@@ -289,7 +289,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
 		if(NewVal)
 			pCurrentLayer->m_Flags |= LAYERFLAG_DETAIL;
 	}
-		
+
 	return pCurrentLayer->RenderProperties(&View);
 }
 
@@ -298,7 +298,7 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 	CQuad *pQuad = pEditor->GetSelectedQuad();
 
 	CUIRect Button;
-	
+
 	// delete button
 	View.HSplitBottom(12.0f, &View, &Button);
 	static int s_DeleteButton = 0;
@@ -335,7 +335,7 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 			}
 
 			int Height = (Right-Left)*pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Height/pEditor->m_Map.m_lImages[pLayer->m_Image]->m_Width;
-			
+
 			pQuad->m_aPoints[0].x = Left; pQuad->m_aPoints[0].y = Top;
 			pQuad->m_aPoints[1].x = Right; pQuad->m_aPoints[1].y = Top;
 			pQuad->m_aPoints[2].x = Left; pQuad->m_aPoints[2].y = Top+Height;
@@ -370,7 +370,7 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 		int Left = pQuad->m_aPoints[0].x;
 		int Bottom = pQuad->m_aPoints[0].y;
 		int Right = pQuad->m_aPoints[0].x;
-		
+
 		for(int k = 1; k < 4; k++)
 		{
 			if(pQuad->m_aPoints[k].y < Top) Top = pQuad->m_aPoints[k].y;
@@ -378,7 +378,7 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 			if(pQuad->m_aPoints[k].y > Bottom) Bottom = pQuad->m_aPoints[k].y;
 			if(pQuad->m_aPoints[k].x > Right) Right = pQuad->m_aPoints[k].x;
 		}
-		
+
 		pQuad->m_aPoints[0].x = Left; pQuad->m_aPoints[0].y = Top;
 		pQuad->m_aPoints[1].x = Right; pQuad->m_aPoints[1].y = Top;
 		pQuad->m_aPoints[2].x = Left; pQuad->m_aPoints[2].y = Bottom;
@@ -398,7 +398,7 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 		PROP_COLOR_ENV_OFFSET,
 		NUM_PROPS,
 	};
-	
+
 	CProperty aProps[] = {
 		{"Pos X", pQuad->m_aPoints[4].x/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
 		{"Pos Y", pQuad->m_aPoints[4].y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
@@ -406,16 +406,16 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 		{"Pos. TO", pQuad->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
 		{"Color Env", pQuad->m_ColorEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
 		{"Color TO", pQuad->m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
-		
+
 		{0},
 	};
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
 	int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
 	if(Prop != -1)
 		pEditor->m_Map.m_Modified = true;
-	
+
 	if(Prop == PROP_POS_X)
 	{
 		float Offset = NewVal*1000-pQuad->m_aPoints[4].x;
@@ -432,14 +432,14 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
 	if(Prop == PROP_POS_ENV_OFFSET) pQuad->m_PosEnvOffset = NewVal;
 	if(Prop == PROP_COLOR_ENV) pQuad->m_ColorEnv = clamp(NewVal-1, -1, pEditor->m_Map.m_lEnvelopes.size()-1);
 	if(Prop == PROP_COLOR_ENV_OFFSET) pQuad->m_ColorEnvOffset = NewVal;
-	
+
 	return 0;
 }
 
 int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
 {
 	CQuad *pQuad = pEditor->GetSelectedQuad();
-	
+
 	enum
 	{
 		PROP_POS_X=0,
@@ -447,7 +447,7 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
 		PROP_COLOR,
 		NUM_PROPS,
 	};
-	
+
 	int Color = 0;
 	int x = 0, y = 0;
 
@@ -465,15 +465,15 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
 			y = pQuad->m_aPoints[v].y/1000;
 		}
 	}
-	
-	
+
+
 	CProperty aProps[] = {
 		{"Pos X", x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
 		{"Pos Y", y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
 		{"Color", Color, PROPTYPE_COLOR, -1, pEditor->m_Map.m_lEnvelopes.size()},
 		{0},
 	};
-	
+
 	static int s_aIds[NUM_PROPS] = {0};
 	int NewVal = 0;
 	int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
@@ -506,8 +506,8 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
 			}
 		}
 	}
-	
-	return 0;	
+
+	return 0;
 }
 
 int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
@@ -520,7 +520,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
 	pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, 0);
 
 	View.HSplitBottom(10.0f, &View, 0);
-	View.HSplitBottom(20.0f, &View, &ButtonBar);	
+	View.HSplitBottom(20.0f, &View, &ButtonBar);
 
 	if(pEditor->m_FileDialogErrString[0] == 0)
 	{
@@ -551,7 +551,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
 				}
 				else
 					str_copy(pEditor->m_FileDialogErrString, "Unable to create the folder", sizeof(pEditor->m_FileDialogErrString));
-			}	
+			}
 		}
 		ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
 		ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
@@ -576,7 +576,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
 			return 1;
 	}
 
-	return 0;	
+	return 0;
 }
 
 int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
@@ -596,7 +596,7 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
 		pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, 0);
 
 	View.HSplitBottom(10.0f, &View, 0);
-	View.HSplitBottom(20.0f, &View, &ButtonBar);	
+	View.HSplitBottom(20.0f, &View, &ButtonBar);
 
 	// notification text
 	View.HSplitTop(30.0f, 0, &View);
@@ -648,18 +648,18 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View)
 	CUIRect ButtonBar, ImageView;
 	View.VSplitLeft(80.0f, &ButtonBar, &View);
 	View.Margin(10.0f, &ImageView);
-	
+
 	int ShowImage = g_SelectImageCurrent;
-	
+
 	for(int i = -1; i < pEditor->m_Map.m_lImages.size(); i++)
 	{
 		CUIRect Button;
 		ButtonBar.HSplitTop(12.0f, &Button, &ButtonBar);
 		ButtonBar.HSplitTop(2.0f, 0, &ButtonBar);
-		
+
 		if(pEditor->UI()->MouseInside(&Button))
 			ShowImage = i;
-			
+
 		if(i == -1)
 		{
 			if(pEditor->DoButton_MenuItem(&pEditor->m_Map.m_lImages[i], "None", i==g_SelectImageCurrent, &Button))
@@ -671,7 +671,7 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View)
 				g_SelectImageSelected = i;
 		}
 	}
-	
+
 	if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size())
 		pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexID);
 	else
@@ -696,7 +696,7 @@ int CEditor::PopupSelectImageResult()
 {
 	if(g_SelectImageSelected == -100)
 		return -100;
-		
+
 	g_SelectImageCurrent = g_SelectImageSelected;
 	g_SelectImageSelected = -100;
 	return g_SelectImageCurrent;
@@ -732,7 +732,7 @@ int CEditor::PopupSelectGameTileOpResult()
 {
 	if(s_GametileOpSelected < 0)
 		return -1;
-	
+
 	int Result = s_GametileOpSelected;
 	s_GametileOpSelected = -1;
 	return Result;