Книга: оглавление в один столбец до 10 глав, в два - до 20 на страницу
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7fd0d405cc
commit
2fa1985a3c
+13
-5
@@ -143,9 +143,12 @@ namespace NecromancerTome
|
||||
[Preserve]
|
||||
public class XUiC_NecroTome : XUiController
|
||||
{
|
||||
/// <summary>Кнопок глав на странице оглавления (btnCh1..10 в windows.xml). Глав будет много (указание 10.10) -
|
||||
/// оглавление листается теми же «Назад/Далее», что и главы.</summary>
|
||||
const int MaxButtons = 10;
|
||||
/// <summary>Кнопки глав в оглавлении (btnCh1..20 в windows.xml). Глав будет много (указание 10.10): до Rows - один
|
||||
/// столбец по центру, больше - два столбца по Rows («я бы их сделал в две колонки»), ещё больше - страницы,
|
||||
/// листаются теми же «Назад/Далее», что и главы.</summary>
|
||||
const int MaxButtons = 20, Rows = 10;
|
||||
/// <summary>Места кнопок (windows.xml: ширина 560, шаг строк 60 от y -130): столбец по центру окна 1300 и два столбца.</summary>
|
||||
const int ColCenterX = 370, ColLeftX = 60, ColRightX = 680, RowTopY = -130, RowStep = 60;
|
||||
|
||||
XUiV_Label _title, _text, _page;
|
||||
XUiV_Texture _img;
|
||||
@@ -216,16 +219,21 @@ namespace NecromancerTome
|
||||
_open.Add(c);
|
||||
}
|
||||
}
|
||||
int pages = Mathf.Max(1, (_open.Count + MaxButtons - 1) / MaxButtons);
|
||||
bool twoCols = _open.Count > Rows;
|
||||
int perPage = twoCols ? MaxButtons : Rows;
|
||||
int pages = Mathf.Max(1, (_open.Count + perPage - 1) / perPage);
|
||||
_tocPage = Mathf.Clamp(_p, 0, pages - 1);
|
||||
int b = 0;
|
||||
for (int i = _tocPage * MaxButtons; i < _open.Count && b < MaxButtons; i++)
|
||||
for (int i = _tocPage * perPage; i < _open.Count && b < perPage; i++)
|
||||
{
|
||||
int c = _open[i];
|
||||
NecroTomeBook.Chapter ch = NecroTomeBook.Chapters[c];
|
||||
_buttonChapter[b] = c;
|
||||
if (_chapterButtons[b] != null)
|
||||
{
|
||||
// Сначала левый столбец сверху вниз, потом правый.
|
||||
int x = !twoCols ? ColCenterX : b < Rows ? ColLeftX : ColRightX;
|
||||
_chapterButtons[b].ViewComponent.Position = new Vector2i(x, RowTopY - RowStep * (b % Rows));
|
||||
_chapterButtons[b].Text = Localization.Get(ch.TitleKey);
|
||||
_chapterButtons[b].ViewComponent.IsVisible = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user