mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Add delete to resume game UI
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"itemType" : "CustomControl",
|
"itemType" : "CustomControl",
|
||||||
"pos" : [ 17, 33 ],
|
"pos" : [ 17, 33 ],
|
||||||
"size" : [ 401, 190 ],
|
"size" : [ 401, 190 ],
|
||||||
"id" : 2,
|
"id" : 3,
|
||||||
"enabled" : true
|
"enabled" : true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -30,9 +30,17 @@
|
|||||||
"itemType" : "CustomControl",
|
"itemType" : "CustomControl",
|
||||||
"pos" : [ 418, 32 ],
|
"pos" : [ 418, 32 ],
|
||||||
"size" : [ 16, 192 ],
|
"size" : [ 16, 192 ],
|
||||||
"id" : 3,
|
"id" : 4,
|
||||||
"enabled" : true
|
"enabled" : true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name" : "Delete",
|
||||||
|
"itemType" : "Button",
|
||||||
|
"pos" : [ 228, 240 ],
|
||||||
|
"size" : [ 58, 20 ],
|
||||||
|
"id" : 5,
|
||||||
|
"enabled" : false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name" : "^0",
|
"name" : "^0",
|
||||||
"itemType" : "Label",
|
"itemType" : "Label",
|
||||||
|
|||||||
29
ApplicationResourcePatches/DITL/2008.json
Normal file
29
ApplicationResourcePatches/DITL/2008.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"items" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "No",
|
||||||
|
"itemType" : "Button",
|
||||||
|
"pos" : [ 253, 99 ],
|
||||||
|
"size" : [ 58, 20 ],
|
||||||
|
"id" : 1,
|
||||||
|
"enabled" : true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Yes",
|
||||||
|
"itemType" : "Button",
|
||||||
|
"pos" : [ 184, 99 ],
|
||||||
|
"size" : [ 58, 20 ],
|
||||||
|
"id" : 2,
|
||||||
|
"enabled" : true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Are you sure that you want to delete this file?",
|
||||||
|
"itemType" : "Label",
|
||||||
|
"pos" : [ 16, 16 ],
|
||||||
|
"size" : [ 295, 74 ],
|
||||||
|
"id" : 0,
|
||||||
|
"enabled" : false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
|
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
|
||||||
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
|
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
|
||||||
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
|
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
|
||||||
|
"DITL/2008.json" : "ApplicationResourcePatches/DITL/2008.json",
|
||||||
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
|
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
|
||||||
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
|
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
|
||||||
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
|
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ static const int kCancelButton = 2;
|
|||||||
static const int kFileList = 3;
|
static const int kFileList = 3;
|
||||||
static const int kFileListScrollBar = 4;
|
static const int kFileListScrollBar = 4;
|
||||||
static const int kFileNameEditBox = 5;
|
static const int kFileNameEditBox = 5;
|
||||||
|
static const int kDeleteButton = 5;
|
||||||
static const int kFileBrowserUIOpenDialogTemplateID = 2001;
|
static const int kFileBrowserUIOpenDialogTemplateID = 2001;
|
||||||
static const int kFileBrowserUISaveDialogTemplateID = 2002;
|
static const int kFileBrowserUISaveDialogTemplateID = 2002;
|
||||||
static const int kFileBrowserUIOverwriteDialogTemplateID = 2003;
|
static const int kFileBrowserUIOverwriteDialogTemplateID = 2003;
|
||||||
static const int kFileBrowserUIBadNameDialogTemplateID = 2004;
|
static const int kFileBrowserUIBadNameDialogTemplateID = 2004;
|
||||||
static const int kFileBrowserUISaveDialogUnobstructiveTemplateID = 2007;
|
static const int kFileBrowserUISaveDialogUnobstructiveTemplateID = 2007;
|
||||||
|
static const int kFileBrowserUIDeleteDialogTemplateID = 2008;
|
||||||
|
|
||||||
|
|
||||||
static const int kOverwriteNoButton = 1;
|
static const int kOverwriteNoButton = 1;
|
||||||
@@ -72,6 +74,8 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
PLPasStr GetSelectedFileName() const;
|
PLPasStr GetSelectedFileName() const;
|
||||||
|
|
||||||
|
void RemoveSelectedFile();
|
||||||
|
|
||||||
static int16_t PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions);
|
static int16_t PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -248,6 +252,22 @@ namespace PortabilityLayer
|
|||||||
return (*m_names)[m_selectedIndex].ToShortStr();
|
return (*m_names)[m_selectedIndex].ToShortStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileBrowserUIImpl::RemoveSelectedFile()
|
||||||
|
{
|
||||||
|
if (m_selectedIndex < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NameStr_t *names = *m_names;
|
||||||
|
for (size_t i = m_selectedIndex; i < m_numNames - 1; i++)
|
||||||
|
names[i] = names[i + 1];
|
||||||
|
|
||||||
|
m_numNames--;
|
||||||
|
PortabilityLayer::MemoryManager::GetInstance()->ResizeHandle(m_names.MMBlock(), sizeof(NameStr_t) * m_numNames);
|
||||||
|
|
||||||
|
m_selectedIndex = -1;
|
||||||
|
DrawFileList();
|
||||||
|
}
|
||||||
|
|
||||||
void FileBrowserUIImpl::ScrollBarCallback(Widget *control, int part)
|
void FileBrowserUIImpl::ScrollBarCallback(Widget *control, int part)
|
||||||
{
|
{
|
||||||
const int pageStepping = 5;
|
const int pageStepping = 5;
|
||||||
@@ -273,6 +293,8 @@ namespace PortabilityLayer
|
|||||||
SetScrollOffset(control->GetState());
|
SetScrollOffset(control->GetState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FileBrowserUI::Mode gs_currentFileBrowserUIMode;
|
||||||
|
|
||||||
int16_t FileBrowserUIImpl::FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt)
|
int16_t FileBrowserUIImpl::FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt)
|
||||||
{
|
{
|
||||||
bool handledIt = false;
|
bool handledIt = false;
|
||||||
@@ -373,6 +395,9 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
dialog->GetItems()[kOkayButton - 1].GetWidget()->SetEnabled(selection >= 0);
|
dialog->GetItems()[kOkayButton - 1].GetWidget()->SetEnabled(selection >= 0);
|
||||||
|
|
||||||
|
if (gs_currentFileBrowserUIMode == FileBrowserUI::Mode_Open)
|
||||||
|
dialog->GetItems()[kDeleteButton - 1].GetWidget()->SetEnabled(selection >= 0);
|
||||||
|
|
||||||
DrawFileList();
|
DrawFileList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,6 +658,8 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
||||||
|
|
||||||
|
gs_currentFileBrowserUIMode = mode;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
hit = dialog->ExecuteModal(&uiImpl, FileBrowserUIImpl::PubFileBrowserUIFilter);
|
hit = dialog->ExecuteModal(&uiImpl, FileBrowserUIImpl::PubFileBrowserUIFilter);
|
||||||
@@ -664,6 +691,23 @@ namespace PortabilityLayer
|
|||||||
hit = -1;
|
hit = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == Mode_Open && hit == kDeleteButton)
|
||||||
|
{
|
||||||
|
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
|
||||||
|
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions);
|
||||||
|
|
||||||
|
if (subHit == kOverwriteYesButton)
|
||||||
|
{
|
||||||
|
PLPasStr uiFileName = uiImpl.GetSelectedFileName();
|
||||||
|
|
||||||
|
PortabilityLayer::FileManager::GetInstance()->DeleteFile(dirID, uiFileName);
|
||||||
|
uiImpl.RemoveSelectedFile();
|
||||||
|
dialog->GetItems()[kOkayButton - 1].GetWidget()->SetEnabled(false);
|
||||||
|
dialog->GetItems()[kDeleteButton - 1].GetWidget()->SetEnabled(false);
|
||||||
|
}
|
||||||
|
hit = -1;
|
||||||
|
}
|
||||||
} while (hit != kOkayButton && hit != kCancelButton);
|
} while (hit != kOkayButton && hit != kCancelButton);
|
||||||
|
|
||||||
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
WindowManager::GetInstance()->SwapExclusiveWindow(exclWindow);
|
||||||
|
|||||||
Reference in New Issue
Block a user