fix formatting issues and clean up indicator selection

This commit is contained in:
marmare314 2023-03-12 18:39:11 +01:00
parent f012716af6
commit 9540d27a10
2 changed files with 12 additions and 12 deletions

View file

@ -1,7 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include "game/client/ui_rect.h"
#include <algorithm>
#include <base/color.h>
@ -4304,10 +4303,11 @@ void CEditor::RenderFileDialog()
Title.VSplitRight(90.0f, &Title, &ButtonFileName);
Title.VSplitRight(10.0f, &Title, nullptr);
std::string aSortIndicator[3] = {"", "", ""};
static int s_ButtonTimeModified = 0;
char aBufLabelButtonTimeModified[64];
str_format(aBufLabelButtonTimeModified, sizeof(aBufLabelButtonTimeModified), "Time modified %s", m_SortByTimeModified == 1 ? "" : m_SortByTimeModified == -1 ? "" :
"");
str_format(aBufLabelButtonTimeModified, sizeof(aBufLabelButtonTimeModified), "Time modified %s", aSortIndicator[m_SortByTimeModified + 1].c_str());
if(DoButton_Editor(&s_ButtonTimeModified, aBufLabelButtonTimeModified, 0, &ButtonTimeModified, 0, "Sort by time modified"))
{
if(m_SortByTimeModified == 1)
@ -4328,8 +4328,7 @@ void CEditor::RenderFileDialog()
static int s_ButtonFileName = 0;
char aBufLabelButtonFilename[64];
str_format(aBufLabelButtonFilename, sizeof(aBufLabelButtonFilename), "Filename %s", m_SortByFilename == 1 ? "" : m_SortByFilename == -1 ? "" :
"");
str_format(aBufLabelButtonFilename, sizeof(aBufLabelButtonFilename), "Filename %s", aSortIndicator[m_SortByFilename + 1].c_str());
if(DoButton_Editor(&s_ButtonFileName, aBufLabelButtonFilename, 0, &ButtonFileName, 0, "Sort by file name"))
{
if(m_SortByFilename == 1)

View file

@ -980,22 +980,22 @@ public:
std::vector<CFilelistItem> m_vCompleteFileList;
std::vector<const CFilelistItem *> m_vpFilteredFileList;
static bool cmp_filename_less(const CFilelistItem *a, const CFilelistItem *b)
static bool cmp_filename_less(const CFilelistItem *a, const CFilelistItem *b)
{
if (str_comp(a->m_aFilename, "..") == 0)
if(str_comp(a->m_aFilename, "..") == 0)
return true;
if (str_comp(b->m_aFilename, "..") == 0)
if(str_comp(b->m_aFilename, "..") == 0)
return false;
if(a->m_IsDir != b->m_IsDir)
return a->m_IsDir;
return str_comp(a->m_aName, b->m_aName) < 0;
}
static bool cmp_filename_greater(const CFilelistItem *a, const CFilelistItem *b)
static bool cmp_filename_greater(const CFilelistItem *a, const CFilelistItem *b)
{
if (str_comp(a->m_aFilename, "..") == 0)
if(str_comp(a->m_aFilename, "..") == 0)
return true;
if (str_comp(b->m_aFilename, "..") == 0)
if(str_comp(b->m_aFilename, "..") == 0)
return false;
if(a->m_IsDir != b->m_IsDir)
return a->m_IsDir;
@ -1009,7 +1009,8 @@ public:
return a->m_TimeModified < b->m_TimeModified;
}
static bool cmp_timemodified_greater(const CFilelistItem *a, const CFilelistItem *b) {
static bool cmp_timemodified_greater(const CFilelistItem *a, const CFilelistItem *b)
{
if(a->m_IsDir != b->m_IsDir)
return a->m_IsDir;
return a->m_TimeModified > b->m_TimeModified;