From 13902fef6c04697f334f4c6b1815e50eb17fdbfc Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 5 Jan 2011 22:22:07 +0100 Subject: [PATCH] show an error popup when demo deletion fails --- src/game/client/components/menus.cpp | 15 +++++++++++++-- src/game/client/components/menus.h | 1 - src/game/client/components/menus_demo.cpp | 16 ---------------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 3d84f2d38..257c278bc 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -53,7 +53,6 @@ CMenus::CMenus() m_NeedSendinfo = false; m_MenuActive = true; m_UseMouseButtons = true; - m_DemolistDelEntry = false; m_EscapePressed = false; m_EnterPressed = false; @@ -1034,7 +1033,19 @@ int CMenus::Render() if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; - m_DemolistDelEntry = true; + // delete demo + if(m_DemolistSelectedIndex >= 0 && !m_DemolistSelectedIsDir) + { + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename); + if(Storage()->RemoveFile(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType)) + { + DemolistPopulate(); + DemolistOnUpdate(false); + } + else + PopupMessage(Localize("Error"), Localize("Unable to delete the demo"), Localize("Ok")); + } } } else if(m_Popup == POPUP_FIRST_LAUNCH) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index c44b9dabf..5e93a90ae 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -180,7 +180,6 @@ class CMenus : public CComponent sorted_array m_lDemos; char m_aCurrentDemoFolder[256]; - bool m_DemolistDelEntry; int m_DemolistSelectedIndex; bool m_DemolistSelectedIsDir; int m_DemolistStorageType; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index b56f4d7f0..8d0a54691 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -477,22 +477,6 @@ void CMenus::RenderDemoList(CUIRect MainView) s_Inited = 1; } - // delete demo - if(m_DemolistDelEntry) - { - if(m_DemolistSelectedIndex >= 0 && !m_DemolistSelectedIsDir) - { - char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "%s/%s", m_aCurrentDemoFolder, m_lDemos[m_DemolistSelectedIndex].m_aFilename); - if(Storage()->RemoveFile(aBuf, m_lDemos[m_DemolistSelectedIndex].m_StorageType)) - { - DemolistPopulate(); - DemolistOnUpdate(false); - } - } - m_DemolistDelEntry = false; - } - char aFooterLabel[128] = {0}; if(m_DemolistSelectedIndex >= 0) {