Книга: оглавление в один столбец до 10 глав, в два - до 20 на страницу

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AlexCube
2026-10-10 13:49:19 +03:00
co-authored by Claude Opus 5.5
parent 7fd0d405cc
commit 2fa1985a3c
2 changed files with 34 additions and 15 deletions
+21 -10
View File
@@ -133,16 +133,27 @@
просвечивают обоями чертогов - красные заголовки сливались, картинка была полупрозрачной. -->
<texture depth="2" name="imgPage" pos="680,-104" width="560" height="640" visible="false" globalopacitymod="0" />
<video depth="2" name="vidPage" pos="680,-104" width="560" height="640" videoaspect="FitInside" loop="true" visible="false" />
<simplebutton name="btnCh1" depth="3" pos="350,-130" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh2" depth="3" pos="350,-190" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh3" depth="3" pos="350,-250" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh4" depth="3" pos="350,-310" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh5" depth="3" pos="350,-370" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh6" depth="3" pos="350,-430" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh7" depth="3" pos="350,-490" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh8" depth="3" pos="350,-550" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh9" depth="3" pos="350,-610" width="600" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh10" depth="3" pos="350,-670" width="600" height="48" font_size="30" visible="false" />
<!-- Кнопки глав: до 10 - один столбец по центру, больше - два столбца по 10 (10.10); места ставит XUiC_NecroTome.ShowToc. -->
<simplebutton name="btnCh1" depth="3" pos="370,-130" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh2" depth="3" pos="370,-190" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh3" depth="3" pos="370,-250" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh4" depth="3" pos="370,-310" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh5" depth="3" pos="370,-370" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh6" depth="3" pos="370,-430" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh7" depth="3" pos="370,-490" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh8" depth="3" pos="370,-550" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh9" depth="3" pos="370,-610" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh10" depth="3" pos="370,-670" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh11" depth="3" pos="370,-130" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh12" depth="3" pos="370,-190" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh13" depth="3" pos="370,-250" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh14" depth="3" pos="370,-310" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh15" depth="3" pos="370,-370" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh16" depth="3" pos="370,-430" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh17" depth="3" pos="370,-490" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh18" depth="3" pos="370,-550" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh19" depth="3" pos="370,-610" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnCh20" depth="3" pos="370,-670" width="560" height="48" font_size="30" visible="false" />
<simplebutton name="btnToc" depth="3" pos="40,-790" width="260" height="46" font_size="26" caption_key="necroTomeToc" />
<simplebutton name="btnPrev" depth="3" pos="440,-790" width="160" height="46" font_size="26" caption_key="necroTomePrev" />
<label depth="2" name="lblPage" pos="600,-772" width="100" height="40" justify="center" font_size="24" color="160,150,140,255" />
+13 -5
View File
@@ -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;
}