Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -0,0 +1,73 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.html.pagehandlers;
import com.l2jmobius.gameserver.model.html.IBypassFormatter;
import com.l2jmobius.gameserver.model.html.IHtmlStyle;
import com.l2jmobius.gameserver.model.html.IPageHandler;
/**
* Creates pager with links 1 2 3 | 9 10 | 998 | 999
* @author UnAfraid
*/
public class DefaultPageHandler implements IPageHandler
{
public static final DefaultPageHandler INSTANCE = new DefaultPageHandler(2);
protected final int _pagesOffset;
public DefaultPageHandler(int pagesOffset)
{
_pagesOffset = pagesOffset;
}
@Override
public void apply(String bypass, int currentPage, int pages, StringBuilder sb, IBypassFormatter bypassFormatter, IHtmlStyle style)
{
final int pagerStart = Math.max(currentPage - _pagesOffset, 0);
final int pagerFinish = Math.min(currentPage + _pagesOffset + 1, pages);
// Show the initial pages in case we are in the middle or at the end
if (pagerStart > _pagesOffset)
{
for (int i = 0; i < _pagesOffset; i++)
{
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, i), String.valueOf(i + 1), currentPage == i));
}
// Separator
sb.append(style.applySeparator());
}
// Show current pages
for (int i = pagerStart; i < pagerFinish; i++)
{
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, i), String.valueOf(i + 1), currentPage == i));
}
// Show the last pages
if (pages > pagerFinish)
{
// Separator
sb.append(style.applySeparator());
for (int i = pages - _pagesOffset; i < pages; i++)
{
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, i), String.valueOf(i + 1), currentPage == i));
}
}
}
}

View File

@@ -0,0 +1,56 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.html.pagehandlers;
import com.l2jmobius.gameserver.model.html.IBypassFormatter;
import com.l2jmobius.gameserver.model.html.IHtmlStyle;
import com.l2jmobius.gameserver.model.html.IPageHandler;
/**
* Creates pager with links << | < | > | >>
* @author UnAfraid
*/
public class NextPrevPageHandler implements IPageHandler
{
public static final NextPrevPageHandler INSTANCE = new NextPrevPageHandler();
@Override
public void apply(String bypass, int currentPage, int pages, StringBuilder sb, IBypassFormatter bypassFormatter, IHtmlStyle style)
{
// Beginning
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, 0), "<<", (currentPage - 1) < 0));
// Separator
sb.append(style.applySeparator());
// Previous
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, currentPage - 1), "<", currentPage <= 0));
sb.append(style.applySeparator());
sb.append(String.format("<td align=\"center\">Page: %d/%d</td>", currentPage + 1, pages + 1));
sb.append(style.applySeparator());
// Next
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, currentPage + 1), ">", currentPage >= pages));
// Separator
sb.append(style.applySeparator());
// End
sb.append(style.applyBypass(bypassFormatter.formatBypass(bypass, pages), ">>", (currentPage + 1) > pages));
}
}