Map Editor: Envelope Preview
[twcon.git] / src / game / editor / editor.h
blob2c94f3f24b2ee140c755bfa6aa4201556431888c
1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef GAME_EDITOR_EDITOR_H
4 #define GAME_EDITOR_EDITOR_H
6 #include <math.h>
8 #include <base/math.h>
9 #include <base/system.h>
11 #include <base/tl/algorithm.h>
12 #include <base/tl/array.h>
13 #include <base/tl/sorted_array.h>
14 #include <base/tl/string.h>
16 #include <game/client/ui.h>
17 #include <game/mapitems.h>
18 #include <game/client/render.h>
20 #include <engine/shared/config.h>
21 #include <engine/shared/datafile.h>
22 #include <engine/editor.h>
23 #include <engine/graphics.h>
25 #include "auto_map.h"
27 typedef void (*INDEX_MODIFY_FUNC)(int *pIndex);
29 //CRenderTools m_RenderTools;
31 // CEditor SPECIFIC
32 enum
34 MODE_LAYERS=0,
35 MODE_IMAGES,
37 DIALOG_NONE=0,
38 DIALOG_FILE,
41 struct CEntity
43 CPoint m_Position;
44 int m_Type;
47 class CEnvelope
49 public:
50 int m_Channels;
51 array<CEnvPoint> m_lPoints;
52 char m_aName[32];
53 float m_Bottom, m_Top;
55 CEnvelope(int Chan)
57 m_Channels = Chan;
58 m_aName[0] = 0;
59 m_Bottom = 0;
60 m_Top = 0;
63 void Resort()
65 sort(m_lPoints.all());
66 FindTopBottom(0xf);
69 void FindTopBottom(int ChannelMask)
71 m_Top = -1000000000.0f;
72 m_Bottom = 1000000000.0f;
73 for(int i = 0; i < m_lPoints.size(); i++)
75 for(int c = 0; c < m_Channels; c++)
77 if(ChannelMask&(1<<c))
79 float v = fx2f(m_lPoints[i].m_aValues[c]);
80 if(v > m_Top) m_Top = v;
81 if(v < m_Bottom) m_Bottom = v;
87 int Eval(float Time, float *pResult)
89 CRenderTools::RenderEvalEnvelope(m_lPoints.base_ptr(), m_lPoints.size(), m_Channels, Time, pResult);
90 return m_Channels;
93 void AddPoint(int Time, int v0, int v1=0, int v2=0, int v3=0)
95 CEnvPoint p;
96 p.m_Time = Time;
97 p.m_aValues[0] = v0;
98 p.m_aValues[1] = v1;
99 p.m_aValues[2] = v2;
100 p.m_aValues[3] = v3;
101 p.m_Curvetype = CURVETYPE_LINEAR;
102 m_lPoints.add(p);
103 Resort();
106 float EndTime()
108 if(m_lPoints.size())
109 return m_lPoints[m_lPoints.size()-1].m_Time*(1.0f/1000.0f);
110 return 0;
115 class CLayer;
116 class CLayerGroup;
117 class CEditorMap;
119 class CLayer
121 public:
122 class CEditor *m_pEditor;
123 class IGraphics *Graphics();
124 class ITextRender *TextRender();
126 CLayer()
128 m_Type = LAYERTYPE_INVALID;
129 str_copy(m_aName, "(invalid)", sizeof(m_aName));
130 m_Visible = true;
131 m_Readonly = false;
132 m_SaveToMap = true;
133 m_Flags = 0;
134 m_pEditor = 0;
137 virtual ~CLayer()
142 virtual void BrushSelecting(CUIRect Rect) {}
143 virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) { return 0; }
144 virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) {}
145 virtual void BrushDraw(CLayer *pBrush, float x, float y) {}
146 virtual void BrushPlace(CLayer *pBrush, float x, float y) {}
147 virtual void BrushFlipX() {}
148 virtual void BrushFlipY() {}
149 virtual void BrushRotate(float Amount) {}
151 virtual void Render() {}
152 virtual int RenderProperties(CUIRect *pToolbox) { return 0; }
154 virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc) {}
155 virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc) {}
157 virtual void GetSize(float *w, float *h) { *w = 0; *h = 0;}
159 char m_aName[12];
160 int m_Type;
161 int m_Flags;
163 bool m_Readonly;
164 bool m_Visible;
165 bool m_SaveToMap;
168 class CLayerGroup
170 public:
171 class CEditorMap *m_pMap;
173 array<CLayer*> m_lLayers;
175 int m_OffsetX;
176 int m_OffsetY;
178 int m_ParallaxX;
179 int m_ParallaxY;
181 int m_UseClipping;
182 int m_ClipX;
183 int m_ClipY;
184 int m_ClipW;
185 int m_ClipH;
187 char m_aName[12];
188 bool m_GameGroup;
189 bool m_Visible;
190 bool m_SaveToMap;
191 bool m_Collapse;
193 CLayerGroup();
194 ~CLayerGroup();
196 void Convert(CUIRect *pRect);
197 void Render();
198 void MapScreen();
199 void Mapping(float *pPoints);
201 void GetSize(float *w, float *h);
203 void DeleteLayer(int Index);
204 int SwapLayers(int Index0, int Index1);
206 bool IsEmpty() const
208 return m_lLayers.size() == 0;
211 void Clear()
213 m_lLayers.delete_all();
216 void AddLayer(CLayer *l);
218 void ModifyImageIndex(INDEX_MODIFY_FUNC Func)
220 for(int i = 0; i < m_lLayers.size(); i++)
221 m_lLayers[i]->ModifyImageIndex(Func);
224 void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
226 for(int i = 0; i < m_lLayers.size(); i++)
227 m_lLayers[i]->ModifyEnvelopeIndex(Func);
231 class CEditorImage : public CImageInfo
233 public:
234 CEditor *m_pEditor;
236 CEditorImage(CEditor *pEditor)
237 : m_AutoMapper(pEditor)
239 m_pEditor = pEditor;
240 m_TexID = -1;
241 m_aName[0] = 0;
242 m_External = 0;
243 m_Width = 0;
244 m_Height = 0;
245 m_pData = 0;
246 m_Format = 0;
249 ~CEditorImage();
251 void AnalyseTileFlags();
253 int m_TexID;
254 int m_External;
255 char m_aName[128];
256 unsigned char m_aTileFlags[256];
257 class CAutoMapper m_AutoMapper;
260 class CEditorMap
262 void MakeGameGroup(CLayerGroup *pGroup);
263 void MakeGameLayer(CLayer *pLayer);
264 public:
265 CEditor *m_pEditor;
266 bool m_Modified;
268 CEditorMap()
270 Clean();
273 array<CLayerGroup*> m_lGroups;
274 array<CEditorImage*> m_lImages;
275 array<CEnvelope*> m_lEnvelopes;
277 class CLayerGame *m_pGameLayer;
278 CLayerGroup *m_pGameGroup;
280 CEnvelope *NewEnvelope(int Channels)
282 m_Modified = true;
283 CEnvelope *e = new CEnvelope(Channels);
284 m_lEnvelopes.add(e);
285 return e;
288 void DeleteEnvelope(int Index);
290 CLayerGroup *NewGroup()
292 m_Modified = true;
293 CLayerGroup *g = new CLayerGroup;
294 g->m_pMap = this;
295 m_lGroups.add(g);
296 return g;
299 int SwapGroups(int Index0, int Index1)
301 if(Index0 < 0 || Index0 >= m_lGroups.size()) return Index0;
302 if(Index1 < 0 || Index1 >= m_lGroups.size()) return Index0;
303 if(Index0 == Index1) return Index0;
304 m_Modified = true;
305 swap(m_lGroups[Index0], m_lGroups[Index1]);
306 return Index1;
309 void DeleteGroup(int Index)
311 if(Index < 0 || Index >= m_lGroups.size()) return;
312 m_Modified = true;
313 delete m_lGroups[Index];
314 m_lGroups.remove_index(Index);
317 void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc)
319 m_Modified = true;
320 for(int i = 0; i < m_lGroups.size(); i++)
321 m_lGroups[i]->ModifyImageIndex(pfnFunc);
324 void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc)
326 m_Modified = true;
327 for(int i = 0; i < m_lGroups.size(); i++)
328 m_lGroups[i]->ModifyEnvelopeIndex(pfnFunc);
331 void Clean();
332 void CreateDefault(int EntitiesTexture);
334 // io
335 int Save(class IStorage *pStorage, const char *pFilename);
336 int Load(class IStorage *pStorage, const char *pFilename, int StorageType);
340 struct CProperty
342 const char *m_pName;
343 int m_Value;
344 int m_Type;
345 int m_Min;
346 int m_Max;
349 enum
351 PROPTYPE_NULL=0,
352 PROPTYPE_BOOL,
353 PROPTYPE_INT_STEP,
354 PROPTYPE_INT_SCROLL,
355 PROPTYPE_COLOR,
356 PROPTYPE_IMAGE,
357 PROPTYPE_ENVELOPE,
358 PROPTYPE_SHIFT,
361 typedef struct
363 int x, y;
364 int w, h;
365 } RECTi;
367 class CLayerTiles : public CLayer
369 public:
370 CLayerTiles(int w, int h);
371 ~CLayerTiles();
373 void Resize(int NewW, int NewH);
374 void Shift(int Direction);
376 void MakePalette();
377 virtual void Render();
379 int ConvertX(float x) const;
380 int ConvertY(float y) const;
381 void Convert(CUIRect Rect, RECTi *pOut);
382 void Snap(CUIRect *pRect);
383 void Clamp(RECTi *pRect);
385 virtual void BrushSelecting(CUIRect Rect);
386 virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect);
387 virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
388 virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
389 virtual void BrushFlipX();
390 virtual void BrushFlipY();
391 virtual void BrushRotate(float Amount);
393 virtual void ShowInfo();
394 virtual int RenderProperties(CUIRect *pToolbox);
396 virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc);
397 virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc);
399 void PrepareForSave();
401 void GetSize(float *w, float *h) { *w = m_Width*32.0f; *h = m_Height*32.0f; }
403 int m_TexID;
404 int m_Game;
405 int m_Image;
406 int m_Width;
407 int m_Height;
408 CColor m_Color;
409 int m_ColorEnv;
410 int m_ColorEnvOffset;
411 CTile *m_pTiles;
414 class CLayerQuads : public CLayer
416 public:
417 CLayerQuads();
418 ~CLayerQuads();
420 virtual void Render();
421 CQuad *NewQuad();
423 virtual void BrushSelecting(CUIRect Rect);
424 virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect);
425 virtual void BrushPlace(CLayer *pBrush, float wx, float wy);
426 virtual void BrushFlipX();
427 virtual void BrushFlipY();
428 virtual void BrushRotate(float Amount);
430 virtual int RenderProperties(CUIRect *pToolbox);
432 virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc);
433 virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc);
435 void GetSize(float *w, float *h);
437 int m_Image;
438 array<CQuad> m_lQuads;
441 class CLayerGame : public CLayerTiles
443 public:
444 CLayerGame(int w, int h);
445 ~CLayerGame();
447 virtual int RenderProperties(CUIRect *pToolbox);
450 class CEditor : public IEditor
452 class IInput *m_pInput;
453 class IClient *m_pClient;
454 class IConsole *m_pConsole;
455 class IGraphics *m_pGraphics;
456 class ITextRender *m_pTextRender;
457 class IStorage *m_pStorage;
458 CRenderTools m_RenderTools;
459 CUI m_UI;
460 public:
461 class IInput *Input() { return m_pInput; };
462 class IClient *Client() { return m_pClient; };
463 class IConsole *Console() { return m_pConsole; };
464 class IGraphics *Graphics() { return m_pGraphics; };
465 class ITextRender *TextRender() { return m_pTextRender; };
466 class IStorage *Storage() { return m_pStorage; };
467 CUI *UI() { return &m_UI; }
468 CRenderTools *RenderTools() { return &m_RenderTools; }
470 CEditor() : m_TilesetPicker(16, 16)
472 m_pInput = 0;
473 m_pClient = 0;
474 m_pGraphics = 0;
475 m_pTextRender = 0;
477 m_Mode = MODE_LAYERS;
478 m_Dialog = 0;
479 m_pTooltip = 0;
481 m_GridActive = false;
482 m_GridFactor = 1;
484 m_aFileName[0] = 0;
485 m_aFileSaveName[0] = 0;
486 m_ValidSaveFilename = false;
488 m_PopupEventActivated = false;
489 m_PopupEventWasActivated = false;
491 m_FileDialogStorageType = 0;
492 m_pFileDialogTitle = 0;
493 m_pFileDialogButtonText = 0;
494 m_pFileDialogUser = 0;
495 m_aFileDialogFileName[0] = 0;
496 m_aFileDialogCurrentFolder[0] = 0;
497 m_aFileDialogCurrentLink[0] = 0;
498 m_pFileDialogPath = m_aFileDialogCurrentFolder;
499 m_aFileDialogActivate = false;
500 m_FileDialogScrollValue = 0.0f;
501 m_FilesSelectedIndex = -1;
502 m_FilesStartAt = 0;
503 m_FilesCur = 0;
504 m_FilesStopAt = 999;
506 m_WorldOffsetX = 0;
507 m_WorldOffsetY = 0;
508 m_EditorOffsetX = 0.0f;
509 m_EditorOffsetY = 0.0f;
511 m_WorldZoom = 1.0f;
512 m_ZoomLevel = 200;
513 m_LockMouse = false;
514 m_ShowMousePointer = true;
515 m_MouseDeltaX = 0;
516 m_MouseDeltaY = 0;
517 m_MouseDeltaWx = 0;
518 m_MouseDeltaWy = 0;
520 m_GuiActive = true;
521 m_ProofBorders = false;
523 m_ShowTileInfo = false;
524 m_ShowDetail = true;
525 m_Animate = false;
526 m_AnimateStart = 0;
527 m_AnimateTime = 0;
528 m_AnimateSpeed = 1;
530 m_ShowEnvelopeEditor = 0;
532 m_ShowEnvelopePreview = 0;
533 m_SelectedQuadEnvelope = -1;
534 m_SelectedEnvelopeChannel = -1;
536 ms_CheckerTexture = 0;
537 ms_BackgroundTexture = 0;
538 ms_CursorTexture = 0;
539 ms_EntitiesTexture = 0;
541 ms_pUiGotContext = 0;
544 virtual void Init();
545 virtual void UpdateAndRender();
546 virtual bool HasUnsavedData() { return m_Map.m_Modified; }
548 void FilelistPopulate(int StorageType);
549 void InvokeFileDialog(int StorageType, int FileType, const char *pTitle, const char *pButtonText,
550 const char *pBasepath, const char *pDefaultName,
551 void (*pfnFunc)(const char *pFilename, int StorageType, void *pUser), void *pUser);
553 void Reset(bool CreateDefault=true);
554 int Save(const char *pFilename);
555 int Load(const char *pFilename, int StorageType);
556 int Append(const char *pFilename, int StorageType);
557 void Render();
559 CQuad *GetSelectedQuad();
560 CLayer *GetSelectedLayerType(int Index, int Type);
561 CLayer *GetSelectedLayer(int Index);
562 CLayerGroup *GetSelectedGroup();
564 int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal);
566 int m_Mode;
567 int m_Dialog;
568 const char *m_pTooltip;
570 bool m_GridActive;
571 int m_GridFactor;
573 char m_aFileName[512];
574 char m_aFileSaveName[512];
575 bool m_ValidSaveFilename;
577 enum
579 POPEVENT_EXIT=0,
580 POPEVENT_LOAD,
581 POPEVENT_NEW,
582 POPEVENT_SAVE,
585 int m_PopupEventType;
586 int m_PopupEventActivated;
587 int m_PopupEventWasActivated;
589 enum
591 FILETYPE_MAP,
592 FILETYPE_IMG,
594 MAX_PATH_LENGTH = 512
597 int m_FileDialogStorageType;
598 const char *m_pFileDialogTitle;
599 const char *m_pFileDialogButtonText;
600 void (*m_pfnFileDialogFunc)(const char *pFileName, int StorageType, void *pUser);
601 void *m_pFileDialogUser;
602 char m_aFileDialogFileName[MAX_PATH_LENGTH];
603 char m_aFileDialogCurrentFolder[MAX_PATH_LENGTH];
604 char m_aFileDialogCurrentLink[MAX_PATH_LENGTH];
605 char *m_pFileDialogPath;
606 bool m_aFileDialogActivate;
607 int m_FileDialogFileType;
608 float m_FileDialogScrollValue;
609 int m_FilesSelectedIndex;
610 char m_FileDialogNewFolderName[64];
611 char m_FileDialogErrString[64];
613 struct CFilelistItem
615 char m_aFilename[128];
616 char m_aName[128];
617 bool m_IsDir;
618 bool m_IsLink;
619 int m_StorageType;
621 bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false :
622 m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false :
623 str_comp_filenames(m_aFilename, Other.m_aFilename) < 0; }
625 sorted_array<CFilelistItem> m_FileList;
626 int m_FilesStartAt;
627 int m_FilesCur;
628 int m_FilesStopAt;
630 float m_WorldOffsetX;
631 float m_WorldOffsetY;
632 float m_EditorOffsetX;
633 float m_EditorOffsetY;
634 float m_WorldZoom;
635 int m_ZoomLevel;
636 bool m_LockMouse;
637 bool m_ShowMousePointer;
638 bool m_GuiActive;
639 bool m_ProofBorders;
640 float m_MouseDeltaX;
641 float m_MouseDeltaY;
642 float m_MouseDeltaWx;
643 float m_MouseDeltaWy;
645 bool m_ShowTileInfo;
646 bool m_ShowDetail;
647 bool m_Animate;
648 int64 m_AnimateStart;
649 float m_AnimateTime;
650 float m_AnimateSpeed;
652 int m_ShowEnvelopeEditor;
653 int m_ShowEnvelopePreview; //Values: 0-Off|1-Selected Envelope|2-All
654 bool m_ShowPicker;
656 int m_SelectedLayer;
657 int m_SelectedGroup;
658 int m_SelectedQuad;
659 int m_SelectedPoints;
660 int m_SelectedEnvelope;
661 int m_SelectedEnvelopeChannel;
662 int m_SelectedQuadEnvelope;
663 int m_SelectedImage;
665 static int ms_CheckerTexture;
666 static int ms_BackgroundTexture;
667 static int ms_CursorTexture;
668 static int ms_EntitiesTexture;
670 CLayerGroup m_Brush;
671 CLayerTiles m_TilesetPicker;
673 static const void *ms_pUiGotContext;
675 CEditorMap m_Map;
677 static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser);
679 void DoMapBorder();
680 int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
681 int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
683 int DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
684 int DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize=10.0f);
685 int DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
686 int DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
688 int DoButton_File(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
690 int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
691 int DoButton_MenuItem(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags=0, const char *pToolTip=0);
693 int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
695 void RenderBackground(CUIRect View, int Texture, float Size, float Brightness);
697 void RenderGrid(CLayerGroup *pGroup);
699 void UiInvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra=0);
700 void UiDoPopupMenu();
702 int UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip);
704 static int PopupGroup(CEditor *pEditor, CUIRect View);
705 static int PopupLayer(CEditor *pEditor, CUIRect View);
706 static int PopupQuad(CEditor *pEditor, CUIRect View);
707 static int PopupPoint(CEditor *pEditor, CUIRect View);
708 static int PopupNewFolder(CEditor *pEditor, CUIRect View);
709 static int PopupEvent(CEditor *pEditor, CUIRect View);
710 static int PopupSelectImage(CEditor *pEditor, CUIRect View);
711 static int PopupSelectGametileOp(CEditor *pEditor, CUIRect View);
712 static int PopupImage(CEditor *pEditor, CUIRect View);
713 static int PopupMenuFile(CEditor *pEditor, CUIRect View);
714 static int PopupSelectConfigAutoMap(CEditor *pEditor, CUIRect View);
716 static void CallbackOpenMap(const char *pFileName, int StorageType, void *pUser);
717 static void CallbackAppendMap(const char *pFileName, int StorageType, void *pUser);
718 static void CallbackSaveMap(const char *pFileName, int StorageType, void *pUser);
720 void PopupSelectImageInvoke(int Current, float x, float y);
721 int PopupSelectImageResult();
723 void PopupSelectGametileOpInvoke(float x, float y);
724 int PopupSelectGameTileOpResult();
726 void PopupSelectConfigAutoMapInvoke(float x, float y);
727 int PopupSelectConfigAutoMapResult();
729 vec4 ButtonColorMul(const void *pID);
731 void DoQuadEnvelopes(CQuad *q, int Index, int texID = -1);
732 void DoQuadEnvPoint(CQuad *pQuad, int Index, int V);
733 void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
735 void DoMapEditor(CUIRect View, CUIRect Toolbar);
736 void DoToolbar(CUIRect Toolbar);
737 void DoQuad(CQuad *pQuad, int Index);
738 float UiDoScrollbarV(const void *pID, const CUIRect *pRect, float Current);
739 vec4 GetButtonColor(const void *pID, int Checked);
741 static void ReplaceImage(const char *pFilename, int StorageType, void *pUser);
742 static void AddImage(const char *pFilename, int StorageType, void *pUser);
744 void RenderImages(CUIRect Toolbox, CUIRect Toolbar, CUIRect View);
745 void RenderLayers(CUIRect Toolbox, CUIRect Toolbar, CUIRect View);
746 void RenderModebar(CUIRect View);
747 void RenderStatusbar(CUIRect View);
748 void RenderEnvelopeEditor(CUIRect View);
750 void RenderMenubar(CUIRect Menubar);
751 void RenderFileDialog();
753 void AddFileDialogEntry(int Index, CUIRect *pView);
754 void SortImages();
755 static void ExtractName(const char *pFileName, char *pName, int BufferSize)
757 const char *pExtractedName = pFileName;
758 const char *pEnd = 0;
759 for(; *pFileName; ++pFileName)
761 if(*pFileName == '/' || *pFileName == '\\')
762 pExtractedName = pFileName+1;
763 else if(*pFileName == '.')
764 pEnd = pFileName;
767 int Length = pEnd > pExtractedName ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize;
768 str_copy(pName, pExtractedName, Length);
771 int GetLineDistance();
774 // make sure to inline this function
775 inline class IGraphics *CLayer::Graphics() { return m_pEditor->Graphics(); }
776 inline class ITextRender *CLayer::TextRender() { return m_pEditor->TextRender(); }
778 #endif