From be5b6aa4de903c5fcd2c24cc1b99435bedce1184 Mon Sep 17 00:00:00 2001 From: xalduin Date: Tue, 1 Jun 2010 16:49:35 -0400 Subject: Sort by map name when opening map When opening a map, the list of map names is now sorted alphabetically. --- src/game/editor/ed_editor.cpp | 36 +++++++++++++++++------------------- src/game/editor/ed_editor.h | 2 ++ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 480a6827..b2b3e1ca 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1,7 +1,8 @@ // copyright (c) 2007 magnus auvinen, see licence.txt for more info #include - +#include +#include #include #include @@ -1885,21 +1886,21 @@ static char gs_FileDialogFileName[512] = {0}; static char gs_aFileDialogPath[512] = {0}; static char gs_aFileDialogCompleteFilename[512] = {0}; static int gs_FilesNum = 0; +static sorted_array gs_FileList; int g_FilesStartAt = 0; int g_FilesCur = 0; int g_FilesStopAt = 999; -struct CListDirInfo -{ - CUIRect *m_pRect; - CEditor *m_pEditor; -}; - static void EditorListdirCallback(const char *pName, int IsDir, void *pUser) { if(pName[0] == '.' || IsDir) // skip this shit! return; + gs_FileList.add(string(pName)); +} + +void CEditor::AddFileDialogEntry(const char *pName, CUIRect *pView) +{ if(g_FilesCur > gs_FilesNum) gs_FilesNum = g_FilesCur; @@ -1907,14 +1908,12 @@ static void EditorListdirCallback(const char *pName, int IsDir, void *pUser) if(g_FilesCur-1 < g_FilesStartAt || g_FilesCur > g_FilesStopAt) return; - CListDirInfo *pInfo = (CListDirInfo *)pUser; - CUIRect *pView = pInfo->m_pRect; CUIRect Button; pView->HSplitTop(15.0f, &Button, pView); pView->HSplitTop(2.0f, 0, pView); //char buf[512]; - if(pInfo->m_pEditor->DoButton_File((void*)(10+(int)Button.y), pName, 0, &Button, 0, 0)) + if(DoButton_File((void*)(10+(int)Button.y), pName, 0, &Button, 0, 0)) { str_copy(gs_FileDialogFileName, pName, sizeof(gs_FileDialogFileName)); @@ -1922,11 +1921,11 @@ static void EditorListdirCallback(const char *pName, int IsDir, void *pUser) str_append(gs_aFileDialogCompleteFilename, gs_aFileDialogPath, sizeof(gs_aFileDialogCompleteFilename)); str_append(gs_aFileDialogCompleteFilename, gs_FileDialogFileName, sizeof(gs_aFileDialogCompleteFilename)); - if(pInfo->m_pEditor->Input()->MouseDoubleClick()) + if(Input()->MouseDoubleClick()) { if(gs_pfnFileDialogFunc) - gs_pfnFileDialogFunc(gs_aFileDialogCompleteFilename, pInfo->m_pEditor); - pInfo->m_pEditor->m_Dialog = DIALOG_NONE; + gs_pfnFileDialogFunc(gs_aFileDialogCompleteFilename, this); + m_Dialog = DIALOG_NONE; } } } @@ -1997,13 +1996,12 @@ void CEditor::RenderFileDialog() // set clipping UI()->ClipEnable(&View); - // the list - CListDirInfo Info; - Info.m_pRect = &View; - Info.m_pEditor = this; - // TODO: lazy ass coding, should store the interface pointer somewere - Kernel()->RequestInterface()->ListDirectory(gs_FileDialogDirTypes, gs_aFileDialogPath, EditorListdirCallback, &Info); + Kernel()->RequestInterface()->ListDirectory(gs_FileDialogDirTypes, gs_aFileDialogPath, EditorListdirCallback, 0); + + for(int i = 0; i < gs_FileList.size(); i++) + AddFileDialogEntry(gs_FileList[i].cstr(), &View); + gs_FileList.clear(); // disable clipping again UI()->ClipDisable(); diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 1730fb0a..d027c162 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -606,6 +606,8 @@ public: void RenderMenubar(CUIRect Menubar); void RenderFileDialog(); + + void AddFileDialogEntry(const char *pName, CUIRect *pView); }; // make sure to inline this function -- cgit 1.4.1 From a99cbfc74238136723a83913b809479267e3dfa2 Mon Sep 17 00:00:00 2001 From: xalduin Date: Wed, 2 Jun 2010 12:12:32 -0400 Subject: Image sorting working, less hackish --- src/game/editor/ed_editor.cpp | 68 +++++++++++++++++++++++++++++++++++++++++-- src/game/editor/ed_editor.h | 1 + 2 files changed, 67 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index b2b3e1ca..df40c48a 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -554,8 +554,24 @@ CQuad *CEditor::GetSelectedQuad() return 0; } -static void CallbackOpenMap(const char *pFileName, void *pUser) { if(((CEditor*)pUser)->Load(pFileName)) str_copy(((CEditor*)pUser)->m_aFileName, pFileName, 512); } -static void CallbackAppendMap(const char *pFileName, void *pUser) { if(((CEditor*)pUser)->Append(pFileName)) ((CEditor*)pUser)->m_aFileName[0] = 0; } +static void CallbackOpenMap(const char *pFileName, void *pUser) +{ + CEditor *pEditor = (CEditor*)pUser; + if(pEditor->Load(pFileName)) + { + str_copy(pEditor->m_aFileName, pFileName, 512); + pEditor->SortImages(); + } +} +static void CallbackAppendMap(const char *pFileName, void *pUser) +{ + CEditor *pEditor = (CEditor*)pUser; + if(pEditor->Append(pFileName)) + { + pEditor->m_aFileName[0] = 0; + pEditor->SortImages(); + } +} static void CallbackSaveMap(const char *pFileName, void *pUser){ if(((CEditor*)pUser)->Save(pFileName)) str_copy(((CEditor*)pUser)->m_aFileName, pFileName, 512); } void CEditor::DoToolbar(CUIRect ToolBar) @@ -1725,6 +1741,7 @@ void CEditor::ReplaceImage(const char *pFileName, void *pUser) *pImg = ImgInfo; ExtractName(pFileName, pImg->m_aName); pImg->m_TexId = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); + pEditor->SortImages(); } void CEditor::AddImage(const char *pFileName, void *pUser) @@ -1747,6 +1764,7 @@ void CEditor::AddImage(const char *pFileName, void *pUser) } pEditor->m_Map.m_lImages.add(pImg); + pEditor->SortImages(); } @@ -1809,9 +1827,55 @@ int CEditor::PopupImage(CEditor *pEditor, CUIRect View) return 0; } +static int CompareImageName(const void *pObject1, const void *pObject2) +{ + CEditorImage *pImage1 = *(CEditorImage**)pObject1; + CEditorImage *pImage2 = *(CEditorImage**)pObject2; + + return str_comp(pImage1->m_aName, pImage2->m_aName); +} + +static int *gs_pSortedIndex = 0; +static void ModifySortedIndex(int *pIndex) +{ + if(*pIndex > -1) + *pIndex = gs_pSortedIndex[*pIndex]; +} + +void CEditor::SortImages() +{ + bool Sorted = true; + for(int i = 1; i < m_Map.m_lImages.size(); i++) + if( str_comp(m_Map.m_lImages[i]->m_aName, m_Map.m_lImages[i-1]->m_aName) < 0 ) + { + Sorted = false; + break; + } + + if(!Sorted) + { + array lTemp = array(m_Map.m_lImages); + gs_pSortedIndex = new int[lTemp.size()]; + + qsort(m_Map.m_lImages.base_ptr(), m_Map.m_lImages.size(), sizeof(CEditorImage*), CompareImageName); + + for(int OldIndex = 0; OldIndex < lTemp.size(); OldIndex++) + for(int NewIndex = 0; NewIndex < m_Map.m_lImages.size(); NewIndex++) + if(lTemp[OldIndex] == m_Map.m_lImages[NewIndex]) + gs_pSortedIndex[OldIndex] = NewIndex; + + m_Map.ModifyImageIndex(ModifySortedIndex); + + delete [] gs_pSortedIndex; + gs_pSortedIndex = 0; + } +} + void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { + SortImages(); + for(int e = 0; e < 2; e++) // two passes, first embedded, then external { CUIRect Slot; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index d027c162..a7d742a8 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -608,6 +608,7 @@ public: void RenderFileDialog(); void AddFileDialogEntry(const char *pName, CUIRect *pView); + void SortImages(); }; // make sure to inline this function -- cgit 1.4.1 From 9e6c9096248dc35a354050749b460fafdd21df7f Mon Sep 17 00:00:00 2001 From: xalduin Date: Wed, 2 Jun 2010 13:26:17 -0400 Subject: Removed unnecessary SortImages call in RenderImages --- src/game/editor/ed_editor.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index df40c48a..0e478753 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1874,8 +1874,6 @@ void CEditor::SortImages() void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { - SortImages(); - for(int e = 0; e < 2; e++) // two passes, first embedded, then external { CUIRect Slot; -- cgit 1.4.1 From 8db32a4b8be19c62ef6d7c3056240a6d608171f6 Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 3 Jun 2010 09:56:57 -0400 Subject: Issue #88 flag pickup distance reduced --- src/game/server/gamemodes/ctf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 05eb973e..705d21ac 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -136,7 +136,7 @@ void CGameControllerCTF::Tick() else { CCharacter *apCloseCCharacters[MAX_CLIENTS]; - int Num = GameServer()->m_World.FindEntities(F->m_Pos, 32.0f, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER); + int Num = GameServer()->m_World.FindEntities(F->m_Pos, 32.0f-(float)g_CharPhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER); for(int i = 0; i < Num; i++) { if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == -1 || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL)) -- cgit 1.4.1 From 3fff61d24aebd77dc6feb289595620e114730c86 Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 3 Jun 2010 10:35:18 -0400 Subject: Issue #86, don't reset score on team switch --- src/game/server/player.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 8e58b7c1..354b8118 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -156,9 +156,11 @@ void CPlayer::SetTeam(int Team) GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); KillCharacter(); + if( m_Team != -1 ) // Give a point to make up for killing character, but not if they're a spectator + m_Score += 1; + m_Team = Team; - m_Score = 0; - m_ScoreStartTick = Server()->Tick(); + //m_ScoreStartTick = Server()->Tick(); // we got to wait 0.5 secs before respawning m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; dbg_msg("game", "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); -- cgit 1.4.1 From 3dc9beb7ec09711471d9949f2b17d944d3915e09 Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 3 Jun 2010 16:24:31 -0400 Subject: Issue #82 time and date in screenshot filename --- src/engine/client/graphics.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 667ba213..e2f4ae4c 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "graphics.h" @@ -868,10 +869,17 @@ void CGraphics_SDL::Swap() char aFilename[128]; static int Index = 1; + time_t Time; + char aDate[20]; + + time(&Time); + tm* TimeInfo = localtime(&Time); + strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo); + for(; Index < 10000; Index++) { IOHANDLE io; - str_format(aFilename, sizeof(aFilename), "screenshots/screenshot%05d.png", Index); + str_format(aFilename, sizeof(aFilename), "screenshots/screenshot%s-%05d.png", aDate, Index); io = m_pStorage->OpenFile(aFilename, IOFLAG_READ); if(io) io_close(io); -- cgit 1.4.1 From 9603d676c67af12294e9598cb8be68fbfafc78e7 Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 3 Jun 2010 17:08:05 -0400 Subject: Score no longer decreased when switching teams --- src/game/server/gamecontroller.cpp | 2 +- src/game/server/player.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 519a28ae..66d84519 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -308,7 +308,7 @@ void IGameController::OnPlayerInfoChange(class CPlayer *pP) int IGameController::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon) { // do scoreing - if(!pKiller) + if(!pKiller || Weapon == WEAPON_GAME) return 0; if(pKiller == pVictim->GetPlayer()) pVictim->GetPlayer()->m_Score--; // suicide diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 354b8118..c295b5d5 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -156,8 +156,6 @@ void CPlayer::SetTeam(int Team) GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); KillCharacter(); - if( m_Team != -1 ) // Give a point to make up for killing character, but not if they're a spectator - m_Score += 1; m_Team = Team; //m_ScoreStartTick = Server()->Tick(); -- cgit 1.4.1 From 848764544faad43ec27dcd60579637aca3d52004 Mon Sep 17 00:00:00 2001 From: Choupom Date: Fri, 4 Jun 2010 22:14:02 +0200 Subject: added folders in demo browser (#25) --- src/base/system.c | 3 +- src/game/client/components/menus.cpp | 2 + src/game/client/components/menus.h | 7 ++- src/game/client/components/menus_demo.cpp | 82 +++++++++++++++++++++++++++---- 4 files changed, 81 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/base/system.c b/src/base/system.c index 47893aa3..a1a1b33e 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -863,8 +863,7 @@ int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user) /* add all the entries */ do { - if(finddata.cFileName[0] != '.') - cb(finddata.cFileName, 0, user); + cb(finddata.cFileName, 0, user); } while (FindNextFileA(handle, &finddata)); FindClose(handle); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index fc919409..76943620 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -94,6 +94,8 @@ CMenus::CMenus() m_NumInputEvents = 0; m_LastInput = time_get(); + + str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder)); } vec4 CMenus::ButtonColorMul(const void *pID) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index c09e6e96..229fce80 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -160,11 +160,14 @@ class CMenus : public CComponent }; sorted_array m_lDemos; - + char m_aCurrentDemoFolder[256]; + void DemolistPopulate(); static void DemolistCountCallback(const char *pName, int IsDir, void *pUser); static void DemolistFetchCallback(const char *pName, int IsDir, void *pUser); - + static void IsDirCallback(const char *pName, int IsDir, void *pUser); + void DemoSetParentDirectory(); + // found in menus.cpp int Render(); //void render_background(); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index f3a6bc88..ec1ead8e 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -1,4 +1,5 @@ +#include #include @@ -390,17 +391,32 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser) pInfo->m_pSelf->m_lDemos.add(Item); } +void CMenus::IsDirCallback(const char *pName, int IsDir, void *pUser) +{ + *((bool *)pUser) = true; +} + void CMenus::DemolistPopulate() { m_lDemos.clear(); + + if(strncmp(m_aCurrentDemoFolder, "demos", 256)) //add parent folder + { + CDemoItem Item; + str_copy(Item.m_aName, "..", sizeof(Item.m_aName)); + str_copy(Item.m_aFilename, "..", sizeof(Item.m_aFilename)); + m_lDemos.add(Item); + } + + char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "%s/demos", Client()->UserDirectory()); - + str_format(aBuf, sizeof(aBuf), "%s/%s", Client()->UserDirectory(), m_aCurrentDemoFolder); + FETCH_CALLBACKINFO Info = {this, aBuf, 0}; fs_listdir(aBuf, DemolistFetchCallback, &Info); - Info.m_pPrefix = "demos"; - fs_listdir("demos", DemolistFetchCallback, &Info); + Info.m_pPrefix = m_aCurrentDemoFolder; + fs_listdir(m_aCurrentDemoFolder, DemolistFetchCallback, &Info); } @@ -439,22 +455,70 @@ void CMenus::RenderDemoList(CUIRect MainView) RefreshRect.VSplitRight(130.0f, &RefreshRect, &PlayRect); PlayRect.VSplitRight(120.0f, 0x0, &PlayRect); + + bool IsDir = false; + if(!strncmp(m_lDemos[s_SelectedItem].m_aName, "..", 256)) //parent folder + IsDir = true; + else + fs_listdir(m_lDemos[s_SelectedItem].m_aFilename, IsDirCallback, &IsDir); + + static int s_RefreshButton = 0; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect)) { DemolistPopulate(); } - + static int s_PlayButton = 0; - if(DoButton_Menu(&s_PlayButton, Localize("Play"), 0, &PlayRect) || Activated) + char aTitleButton[8]; + if(IsDir) + str_copy(aTitleButton, "Open", sizeof(aTitleButton)); + else + str_copy(aTitleButton, "Play", sizeof(aTitleButton)); + // /!\ TODO: Add "Open" in Localization /!\ + if(DoButton_Menu(&s_PlayButton, Localize(aTitleButton), 0, &PlayRect) || Activated) { if(s_SelectedItem >= 0 && s_SelectedItem < m_lDemos.size()) { - const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename); - if(pError) - PopupMessage(Localize("Error"), Localize(pError), Localize("Ok")); + if(!strncmp(m_lDemos[s_SelectedItem].m_aName, "..", 256)) + { + DemoSetParentDirectory(); + DemolistPopulate(); + s_SelectedItem = 0; + } + else if(IsDir) + { + str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", m_aCurrentDemoFolder, m_lDemos[s_SelectedItem].m_aName); + DemolistPopulate(); + s_SelectedItem = 0; + } + else + { + const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename); + if(pError) + PopupMessage(Localize("Error"), pError, Localize("Ok")); + } } } } + + +void CMenus::DemoSetParentDirectory() +{ + int Stop = 0; + int i; + for(i = 0; i < 256; i++) + { + if(m_aCurrentDemoFolder[i] == '/') + Stop = i; + } + + //keeps chars which are before the last '/' and remove chars which are after + for(i = 0; i < 256; i++) + { + if(i >= Stop) + m_aCurrentDemoFolder[i] = NULL; + } +} -- cgit 1.4.1 From 747d972d389ab39ad712a766b9ca5e0598f87b21 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 5 Jun 2010 10:44:50 +0200 Subject: fixed so we can run a map which is in a folder --- src/engine/server/server.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 6dd5a959..96071ceb 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -552,8 +552,16 @@ int CServer::DelClientCallback(int ClientId, void *pUser) void CServer::SendMap(int ClientId) { + //get the name of the map without his path + char * pMapShortName = &g_Config.m_SvMap[0]; + for(int i = 0; i < 128; i++) + { + if(g_Config.m_SvMap[i] == '/' || g_Config.m_SvMap[i] == '\\' && i+1 < 128) + pMapShortName = &g_Config.m_SvMap[i+1]; + } + CMsgPacker Msg(NETMSG_MAP_CHANGE); - Msg.AddString(g_Config.m_SvMap, 0); + Msg.AddString(pMapShortName, 0); Msg.AddInt(m_CurrentMapCrc); SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true); } -- cgit 1.4.1 From 80a7c53dec3e2fefbdf854ef32efb242662179a7 Mon Sep 17 00:00:00 2001 From: xalduin Date: Sat, 5 Jun 2010 18:46:47 -0400 Subject: Issue #92 scrollbars added for layer/image toolbars --- src/game/editor/ed_editor.cpp | 174 +++++++++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 35a0b03a..44620ab9 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -567,10 +567,7 @@ static void CallbackAppendMap(const char *pFileName, void *pUser) { CEditor *pEditor = (CEditor*)pUser; if(pEditor->Append(pFileName)) - { pEditor->m_aFileName[0] = 0; - pEditor->SortImages(); - } } static void CallbackSaveMap(const char *pFileName, void *pUser){ if(((CEditor*)pUser)->Save(pFileName)) str_copy(((CEditor*)pUser)->m_aFileName, pFileName, 512); } @@ -1045,13 +1042,13 @@ void CEditor::DoQuadPoint(CQuad *q, int QuadIndex, int v) s_Operation = OP_CONTEXT_MENU; m_SelectedQuad = QuadIndex; UI()->SetActiveItem(pId); - if(!(m_SelectedPoints&(1<KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) - m_SelectedPoints |= 1<KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) + m_SelectedPoints |= 1<= 0 && m_SelectedLayer < m_Map.m_lGroups[m_SelectedGroup]->m_lLayers.size()) ValidLayer = 1; + int Num = (int)(View.h/16.0f); + static int s_ScrollBar = 0; + static float s_ScrollValue = 0; + + int LayerNum = 0; + for(int g = 0; g < m_Map.m_lGroups.size(); g++) + LayerNum += m_Map.m_lGroups[g]->m_lLayers.size() + 1; + + int ScrollNum = LayerNum-Num+10; + + if(LayerNum > Num) // Do we even need a scrollbar? + { + CUIRect Scroll; + LayersBox.VSplitRight(15.0f, &LayersBox, &Scroll); + LayersBox.VSplitRight(3.0f, &LayersBox, 0); // extra spacing + Scroll.HMargin(5.0f, &Scroll); + s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); + + if(ScrollNum > 0) + { + if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) + s_ScrollValue -= 3.0f/ScrollNum; + if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) + s_ScrollValue += 3.0f/ScrollNum; + + if(s_ScrollValue < 0) s_ScrollValue = 0; + if(s_ScrollValue > 1) s_ScrollValue = 1; + } + else + ScrollNum = 0; + } + + int LayerStartAt = (int)(ScrollNum*s_ScrollValue); + if(LayerStartAt < 0) + LayerStartAt = 0; + + int LayerStopAt = LayerStartAt+Num; + int LayerCur = 0; + // render layers { for(int g = 0; g < m_Map.m_lGroups.size(); g++) { + if(LayerCur > LayerStopAt) + break; + else if(LayerCur + m_Map.m_lGroups[g]->m_lLayers.size() + 1 < LayerStartAt) + { + LayerCur += m_Map.m_lGroups[g]->m_lLayers.size() + 1; + continue; + } + CUIRect VisibleToggle; - LayersBox.HSplitTop(12.0f, &Slot, &LayersBox); - Slot.VSplitLeft(12, &VisibleToggle, &Slot); - if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", 0, &VisibleToggle, 0, "Toggle group visibility", CUI::CORNER_L)) - m_Map.m_lGroups[g]->m_Visible = !m_Map.m_lGroups[g]->m_Visible; - - str_format(aBuf, sizeof(aBuf),"#%d %s", g, m_Map.m_lGroups[g]->m_pName); - if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot, - BUTTON_CONTEXT, "Select group. Right click for properties.", CUI::CORNER_R)) + if(LayerCur >= LayerStartAt) { - m_SelectedGroup = g; - m_SelectedLayer = 0; + LayersBox.HSplitTop(12.0f, &Slot, &LayersBox); + Slot.VSplitLeft(12, &VisibleToggle, &Slot); + if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", 0, &VisibleToggle, 0, "Toggle group visibility", CUI::CORNER_L)) + m_Map.m_lGroups[g]->m_Visible = !m_Map.m_lGroups[g]->m_Visible; - static int s_GroupPopupId = 0; - if(Result == 2) - UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupGroup); - } + str_format(aBuf, sizeof(aBuf),"#%d %s", g, m_Map.m_lGroups[g]->m_pName); + if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot, + BUTTON_CONTEXT, "Select group. Right click for properties.", CUI::CORNER_R)) + { + m_SelectedGroup = g; + m_SelectedLayer = 0; - LayersBox.HSplitTop(2.0f, &Slot, &LayersBox); + static int s_GroupPopupId = 0; + if(Result == 2) + UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupGroup); + } + LayersBox.HSplitTop(2.0f, &Slot, &LayersBox); + } + LayerCur++; for(int i = 0; i < m_Map.m_lGroups[g]->m_lLayers.size(); i++) { + if(LayerCur < LayerStartAt || LayerCur > LayerStopAt) + { + LayerCur++; + continue; + } + //visible LayersBox.HSplitTop(12.0f, &Slot, &LayersBox); Slot.VSplitLeft(12.0f, 0, &Button); @@ -1682,14 +1735,14 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 150, PopupLayer); } - + LayerCur++; LayersBox.HSplitTop(2.0f, &Slot, &LayersBox); } LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); } } - + if(LayerCur <= LayerStopAt) { LayersBox.HSplitTop(12.0f, &Slot, &LayersBox); @@ -1701,7 +1754,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) } } - LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); + //LayersBox.HSplitTop(5.0f, &Slot, &LayersBox); } @@ -1882,14 +1935,58 @@ void CEditor::SortImages() void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { + int Num = (int)(View.h/15.0f); + static int s_ScrollBar = 0; + static float s_ScrollValue = 0; + + int ImageNum = m_Map.m_lImages.size(); + int ScrollNum = ImageNum-Num+10; + + if(ImageNum > Num) // Do we even need a scrollbar? + { + CUIRect Scroll; + ToolBox.VSplitRight(15.0f, &ToolBox, &Scroll); + ToolBox.VSplitRight(3.0f, &ToolBox, 0); // extra spacing + Scroll.HMargin(5.0f, &Scroll); + s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); + + if(ScrollNum > 0) + { + if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) + s_ScrollValue -= 3.0f/ScrollNum; + if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) + s_ScrollValue += 3.0f/ScrollNum; + + if(s_ScrollValue < 0) s_ScrollValue = 0; + if(s_ScrollValue > 1) s_ScrollValue = 1; + } + else + ScrollNum = 0; + } + + int ImageStartAt = (int)(ScrollNum*s_ScrollValue); + if(ImageStartAt < 0) + ImageStartAt = 0; + + int ImageStopAt = ImageStartAt+Num; + int ImageCur = 0; + for(int e = 0; e < 2; e++) // two passes, first embedded, then external { CUIRect Slot; - ToolBox.HSplitTop(15.0f, &Slot, &ToolBox); - if(e == 0) - UI()->DoLabel(&Slot, "Embedded", 12.0f, 0); - else - UI()->DoLabel(&Slot, "External", 12.0f, 0); + + if(ImageCur > ImageStopAt) + break; + else if(ImageCur >= ImageStartAt) + { + + ToolBox.HSplitTop(15.0f, &Slot, &ToolBox); + if(e == 0) + UI()->DoLabel(&Slot, "Embedded", 12.0f, 0); + else + UI()->DoLabel(&Slot, "External", 12.0f, 0); + } + ImageCur++; for(int i = 0; i < m_Map.m_lImages.size(); i++) { @@ -1899,6 +1996,15 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) continue; } + if(ImageCur > ImageStopAt) + break; + else if(ImageCur < ImageStartAt) + { + ImageCur++; + continue; + } + ImageCur++; + char aBuf[128]; str_copy(aBuf, m_Map.m_lImages[i]->m_aName, sizeof(aBuf)); ToolBox.HSplitTop(12.0f, &Slot, &ToolBox); @@ -2626,7 +2732,7 @@ void CEditor::Render() View.HSplitTop(16.0f, &MenuBar, &View); View.HSplitTop(53.0f, &ToolBar, &View); - View.VSplitLeft(80.0f, &ToolBox, &View); + View.VSplitLeft(100.0f, &ToolBox, &View); View.HSplitBottom(16.0f, &View, &StatusBar); if(m_ShowEnvelopeEditor) -- cgit 1.4.1 From 2d99a0360fa4ca08525c93ba81469fb2b4cc7e72 Mon Sep 17 00:00:00 2001 From: xalduin Date: Sat, 5 Jun 2010 18:47:30 -0400 Subject: Images are now sorted on Append --- src/game/editor/ed_editor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 44620ab9..07761441 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -568,6 +568,8 @@ static void CallbackAppendMap(const char *pFileName, void *pUser) CEditor *pEditor = (CEditor*)pUser; if(pEditor->Append(pFileName)) pEditor->m_aFileName[0] = 0; + else + pEditor->SortImages(); } static void CallbackSaveMap(const char *pFileName, void *pUser){ if(((CEditor*)pUser)->Save(pFileName)) str_copy(((CEditor*)pUser)->m_aFileName, pFileName, 512); } -- cgit 1.4.1 From 442e6e14315350bb52646191c27ef20d88e3e8fc Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 6 Jun 2010 14:31:16 +0200 Subject: fixed issue when using +commands in the console --- src/engine/shared/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index c545b7db..eacf9b78 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -273,7 +273,8 @@ CConsole::CCommand *CConsole::FindCommand(const char *pName) void CConsole::ExecuteLine(const char *pStr) { - CConsole::ExecuteLineStroked(1, pStr); + CConsole::ExecuteLineStroked(1, pStr); // press it + CConsole::ExecuteLineStroked(0, pStr); // then release it } -- cgit 1.4.1 From a41d930a85f31064965d89115d851518d568f175 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 5 Jun 2010 13:38:08 +0200 Subject: fixed some compiler warnings. Closes #76 --- src/engine/external/pnglite/pnglite.h | 2 +- src/game/client/components/console.cpp | 14 +++++++++++--- src/game/client/components/console.h | 3 ++- src/game/server/entities/character.h | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/engine/external/pnglite/pnglite.h b/src/engine/external/pnglite/pnglite.h index 72ff1c52..eae3d4ce 100644 --- a/src/engine/external/pnglite/pnglite.h +++ b/src/engine/external/pnglite/pnglite.h @@ -73,7 +73,7 @@ enum typedef unsigned (*png_write_callback_t)(void* input, unsigned long size, unsigned long numel, void* user_pointer); typedef unsigned (*png_read_callback_t)(void* output, unsigned long size, unsigned long numel, void* user_pointer); typedef void (*png_free_t)(void* p); -typedef void * (*png_alloc_t)(unsigned long s); +typedef void * (*png_alloc_t)(size_t s); typedef struct { diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 742b6b2d..b323ab48 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -34,9 +34,8 @@ enum CONSOLE_CLOSING, }; -CGameConsole::CInstance::CInstance(CGameConsole *pGameConsole, int Type) +CGameConsole::CInstance::CInstance(int Type) { - m_pGameConsole = pGameConsole; // init ringbuffers //history = ringbuf_init(history_data, sizeof(history_data), RINGBUF_FLAG_RECYCLE); //backlog = ringbuf_init(backlog_data, sizeof(backlog_data), RINGBUF_FLAG_RECYCLE); @@ -56,6 +55,11 @@ CGameConsole::CInstance::CInstance(CGameConsole *pGameConsole, int Type) m_pCommand = 0x0; } +void CGameConsole::CInstance::Init(CGameConsole *pGameConsole) +{ + m_pGameConsole = pGameConsole; +}; + void CGameConsole::CInstance::ExecuteLine(const char *pLine) { if(m_Type == 0) @@ -198,7 +202,7 @@ void CGameConsole::CInstance::PrintLine(const char *pLine) } CGameConsole::CGameConsole() -: m_LocalConsole(this, 0), m_RemoteConsole(this, 1) +: m_LocalConsole(0), m_RemoteConsole(1) { m_ConsoleType = 0; m_ConsoleState = CONSOLE_CLOSED; @@ -573,6 +577,10 @@ void CGameConsole::PrintLine(int Type, const char *pLine) void CGameConsole::OnConsoleInit() { + // init console instances + m_LocalConsole.Init(this); + m_RemoteConsole.Init(this); + m_pConsole = Kernel()->RequestInterface(); // diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index b88c6349..d146307f 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -27,7 +27,8 @@ class CGameConsole : public CComponent IConsole::CCommandInfo *m_pCommand; - CInstance(CGameConsole *pGameConsole, int t); + CInstance(int t); + void Init(CGameConsole *pGameConsole); void ExecuteLine(const char *pLine); diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index a1add982..bea0c002 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -57,7 +57,7 @@ public: void SetEmote(int Emote, int Tick); - const bool IsAlive() { return m_Alive; } + bool IsAlive() const { return m_Alive; } class CPlayer *GetPlayer() { return m_pPlayer; } private: -- cgit 1.4.1 From 04b6abae93c809efeeb4f6b2e9d8eb80a48b1686 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 6 Jun 2010 15:38:03 +0200 Subject: fixed kill messages showing wrong infos --- src/game/client/components/killmessages.cpp | 36 ++++++++++++++++++----------- src/game/client/components/killmessages.h | 10 ++++++-- 2 files changed, 31 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index d18dd965..a3dc3b9c 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -22,8 +22,14 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) // unpack messages CKillMsg Kill; - Kill.m_Killer = pMsg->m_Killer; - Kill.m_Victim = pMsg->m_Victim; + Kill.m_VictimID = pMsg->m_Victim; + Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team; + str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_VictimID].m_aName, sizeof(Kill.m_aVictimName)); + Kill.m_VictimRenderInfo = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; + Kill.m_KillerID = pMsg->m_Killer; + Kill.m_KillerTeam = m_pClient->m_aClients[Kill.m_KillerID].m_Team; + str_copy(Kill.m_aKillerName, m_pClient->m_aClients[Kill.m_KillerID].m_aName, sizeof(Kill.m_aKillerName)); + Kill.m_KillerRenderInfo = m_pClient->m_aClients[Kill.m_KillerID].m_RenderInfo; Kill.m_Weapon = pMsg->m_Weapon; Kill.m_ModeSpecial = pMsg->m_ModeSpecial; Kill.m_Tick = Client()->GameTick(); @@ -51,14 +57,14 @@ void CKillMessages::OnRender() continue; float FontSize = 36.0f; - float KillerNameW = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_aName, -1); - float VictimNameW = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_aName, -1); + float KillerNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aKillerName, -1); + float VictimNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aVictimName, -1); float x = StartX; // render victim name x -= VictimNameW; - TextRender()->Text(0, x, y, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_aName, -1); + TextRender()->Text(0, x, y, FontSize, m_aKillmsgs[r].m_aVictimName, -1); // render victim tee x -= 24.0f; @@ -71,8 +77,10 @@ void CKillMessages::OnRender() Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); - if(m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE); - else RenderTools()->SelectSprite(SPRITE_FLAG_RED); + if(m_aKillmsgs[r].m_VictimTeam == 0) + RenderTools()->SelectSprite(SPRITE_FLAG_BLUE); + else + RenderTools()->SelectSprite(SPRITE_FLAG_RED); float Size = 56.0f; IGraphics::CQuadItem QuadItem(x, y-16, Size/2, Size); @@ -81,7 +89,7 @@ void CKillMessages::OnRender() } } - RenderTools()->RenderTee(CAnimState::GetIdle(), &m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_RenderInfo, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); + RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_VictimRenderInfo, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); x -= 32.0f; // render weapon @@ -96,7 +104,7 @@ void CKillMessages::OnRender() } x -= 52.0f; - if(m_aKillmsgs[r].m_Victim != m_aKillmsgs[r].m_Killer) + if(m_aKillmsgs[r].m_VictimID != m_aKillmsgs[r].m_KillerID) { if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_FLAGS) { @@ -106,8 +114,10 @@ void CKillMessages::OnRender() Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); - if(m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); - else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); + if(m_aKillmsgs[r].m_KillerTeam == 0) + RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); + else + RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); float Size = 56.0f; IGraphics::CQuadItem QuadItem(x-56, y-16, Size/2, Size); @@ -118,12 +128,12 @@ void CKillMessages::OnRender() // render killer tee x -= 24.0f; - RenderTools()->RenderTee(CAnimState::GetIdle(), &m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_RenderInfo, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); + RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_KillerRenderInfo, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); x -= 32.0f; // render killer name x -= KillerNameW; - TextRender()->Text(0, x, y, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_aName, -1); + TextRender()->Text(0, x, y, FontSize, m_aKillmsgs[r].m_aKillerName, -1); } y += 44; diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index 720b10ae..b4954e22 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -9,8 +9,14 @@ public: struct CKillMsg { int m_Weapon; - int m_Victim; - int m_Killer; + int m_VictimID; + int m_VictimTeam; + char m_aVictimName[64]; + CTeeRenderInfo m_VictimRenderInfo; + int m_KillerID; + int m_KillerTeam; + char m_aKillerName[64]; + CTeeRenderInfo m_KillerRenderInfo; int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example int m_Tick; }; -- cgit 1.4.1