Skip to content

Commit

Permalink
fixed download map view
Browse files Browse the repository at this point in the history
  • Loading branch information
Robosturm committed Dec 4, 2023
1 parent 1df94ad commit 040f348
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
10 changes: 7 additions & 3 deletions multiplayer/dialogselectdownloadmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DialogSelectDownloadMap::showMapFilter()

qint32 DialogSelectDownloadMap::getCurrentPage() const
{
return m_currentStartIndex % ITEMS_PER_PAGE;
return m_currentStartIndex / ITEMS_PER_PAGE;
}

void DialogSelectDownloadMap::changeCurrentPageToEnd(bool start)
Expand All @@ -51,6 +51,7 @@ void DialogSelectDownloadMap::changeCurrentPageToEnd(bool start)

void DialogSelectDownloadMap::changeCurrentPage(qint32 direction)
{
auto curIdx = m_currentStartIndex;
if (direction > 0)
{
m_currentStartIndex += ITEMS_PER_PAGE;
Expand All @@ -63,12 +64,15 @@ void DialogSelectDownloadMap::changeCurrentPage(qint32 direction)
{
m_currentStartIndex = 0;
}
qint32 pageCount = getPageCount();
qint32 pageCount = getPageCount() * ITEMS_PER_PAGE;
if (m_currentStartIndex >= pageCount)
{
m_currentStartIndex = pageCount - 1;
}
filterChanged();
if (curIdx != m_currentStartIndex)
{
filterChanged();
}
}

qint32 DialogSelectDownloadMap::getPageCount()
Expand Down
1 change: 1 addition & 0 deletions network/mapfileserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void MapFileServer::onRequestFilteredMaps(quint64 socketID, const QJsonObject &
QJsonArray foundMaps;
if (query.seek(startItem))
{
itemCount = startItem;
do
{
++itemCount;
Expand Down
1 change: 1 addition & 0 deletions objects/dialogs/customdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void CustomDialog::loadXmlFile(const QString& uiXml)

void CustomDialog::refreshUi()
{
resetUi();
loadXmlFile(m_uiXml);
}

Expand Down
38 changes: 20 additions & 18 deletions resources/ui/multiplayer/selectDownloadMap.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
var SelectDownloadMap =
{
curHeightPos : 10,

updateY : function()
{
SelectDownloadMap.curHeightPos = lastY + lastHeight + 10
},

nextHeightPos : 10,
updateMapY : function()
{
var y = currentMenu.getMapImageHeight(loopIdx);
if (y > SelectDownloadMap.curHeightPos)
var y = currentMenu.getMapImageHeight(loopIdx) + SelectDownloadMap.curHeightPos + 10;
if (y > lastY + lastHeight + 10)
{
SelectDownloadMap.curHeightPos = y;
SelectDownloadMap.nextHeightPos = y;
}
else
{
SelectDownloadMap.nextHeightPos = lastY + lastHeight + 10;
}
},
getAndUpdateMapY : function()
{
SelectDownloadMap.updateY();
return lastY + lastHeight + 10;
},

getMapY : function()
{
SelectDownloadMap.updateMapY();
return 10;
if (loopIdx === 0)
{
return 10;
}
else
{
return SelectDownloadMap.curHeightPos + 10;
}
},

getInitialY : function()
{
if (loopIdx === 0)
{
SelectDownloadMap.curHeightPos = 10;
SelectDownloadMap.nextHeightPos = 10;
return 10;
}
else
{
SelectDownloadMap.curHeightPos = SelectDownloadMap.nextHeightPos;
return SelectDownloadMap.curHeightPos + 10;
}
},
Expand All @@ -43,7 +45,7 @@ var SelectDownloadMap =
var pageCount = currentMenu.getPageCount();
if (pageCount > 0)
{
var curPage = currentMenu.getCurrentPage();
var curPage = currentMenu.getCurrentPage() + 1;
return curPage.toString() + " / " + pageCount.toString();
}
else
Expand Down
4 changes: 2 additions & 2 deletions resources/ui/multiplayer/selectDownloadMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</Label>
<Button>
<x>10</x>
<y>SelectDownloadMap.getAndUpdateMapY()</y>
<y>lastY + lastHeight + 10</y>
<width>150</width>
<text>QT_TRANSLATE_NOOP("GAME","Download")</text>
<tooltip>QT_TRANSLATE_NOOP("GAME","Downloads this map from the server.")</tooltip>
Expand All @@ -123,7 +123,7 @@
<IconButton>
<x>lastX + lastWidth + 10</x>
<y>lastY</y>
<sprite>"toStart"</sprite>
<sprite>"previous_unit"</sprite>
<tooltip>QT_TRANSLATE_NOOP("GAME","Goes to the previous page.")</tooltip>
<onEvent>currentMenu.changeCurrentPage(-1);</onEvent>
</IconButton>
Expand Down

0 comments on commit 040f348

Please sign in to comment.