Finished text parser
This commit is contained in:
parent
d439ac92fc
commit
832ed15060
11 changed files with 323 additions and 127 deletions
|
@ -79,8 +79,9 @@ public class GuiIndex extends GuiScreen{
|
|||
|
||||
if(entries != null && !entries.isEmpty()){
|
||||
int j = 0;
|
||||
for(int i = 0; i < entries.size(); i++){
|
||||
Entry entry = (Entry)entries.values().toArray()[i];
|
||||
Entry[] entryList = EntryRegistry.getEntriesInOrderForCategory(category);
|
||||
for(int i = 0; i < entryList.length; i++){
|
||||
Entry entry = entryList[i];
|
||||
if(entry != null && entry.indexPage == this.currPage){
|
||||
x = this.left + gwidth / 2 - 75;
|
||||
y = (top + 15) + (10*j);
|
||||
|
@ -125,11 +126,13 @@ public class GuiIndex extends GuiScreen{
|
|||
}
|
||||
|
||||
public void registerButtons(){
|
||||
HashMap<String, Entry> entries = EntryRegistry.entries.get(this.category);
|
||||
HashMap<String, Entry> entries = EntryRegistry.entries.get(this.category);
|
||||
|
||||
if(entries != null && !entries.isEmpty()){
|
||||
Entry[] entryList = EntryRegistry.getEntriesInOrderForCategory(category);
|
||||
int j = 0;
|
||||
for(int i = 0; i < entries.size(); i++){
|
||||
Entry entry = (Entry)entries.values().toArray()[i];
|
||||
for(int i = 0; i < entryList.length; i++){
|
||||
Entry entry = entryList[i];
|
||||
|
||||
if(entry != null && entry.indexPage == this.currPage){
|
||||
String title = entry.name;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class EntryText implements IEntry{
|
|||
if(this.entryName == null)
|
||||
this.entryName = key;
|
||||
|
||||
String s = StatCollector.translateToLocal("bu.entry." + this.entryName + "." + page);
|
||||
String s = StatCollector.translateToLocal("aw.entry." + this.entryName + "." + page);
|
||||
x = left + width / 2 - 58;
|
||||
y = (top + 15);
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package WayofTime.alchemicalWizardry.book.interfaces;
|
||||
|
||||
import WayofTime.alchemicalWizardry.book.compact.Entry;
|
||||
|
||||
public class StringEntry
|
||||
{
|
||||
public String str;
|
||||
public Entry entry;
|
||||
public StringEntry(String str, Entry ent)
|
||||
{
|
||||
this.str = str;
|
||||
this.entry = ent;
|
||||
}
|
||||
}
|
|
@ -2,24 +2,31 @@ package WayofTime.alchemicalWizardry.book.registries;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.alchemicalWizardry.book.compact.Category;
|
||||
import WayofTime.alchemicalWizardry.book.compact.Entry;
|
||||
|
||||
public class EntryRegistry {
|
||||
public static void registerCategories(Category category){
|
||||
public class EntryRegistry
|
||||
{
|
||||
public static void registerCategories(Category category)
|
||||
{
|
||||
categories.add(category);
|
||||
categoryMap.put(category.name, category);
|
||||
entryOrder.put(category, new ArrayList());
|
||||
categoryCount++;
|
||||
}
|
||||
public static ArrayList<Category> categories = new ArrayList<Category>();
|
||||
public static HashMap<Category, List<String>> entryOrder = new HashMap();
|
||||
public static HashMap<String, Category> categoryMap = new HashMap<String, Category>();
|
||||
|
||||
public static int categoryCount = 0;
|
||||
|
||||
public static void registerEntry(Category category, HashMap<String, Entry> entryMap, Entry entry){
|
||||
public static void registerEntry(Category category, HashMap<String, Entry> entryMap, Entry entry)
|
||||
{
|
||||
entryMap.put(entry.name, entry);
|
||||
entries.put(category, entryMap);
|
||||
entryOrder.get(category).add(entry.name);
|
||||
|
||||
if(maxEntries.containsKey(category) && entry.indexPage > maxEntries.get(category))
|
||||
maxEntries.put(category, entry.indexPage);
|
||||
|
@ -36,4 +43,26 @@ public class EntryRegistry {
|
|||
public static HashMap<String, Entry> rituals = new HashMap<String, Entry>();
|
||||
public static HashMap<String, Entry> bloodUtils = new HashMap<String, Entry>();
|
||||
|
||||
public static Entry[] getEntriesInOrderForCategory(Category category)
|
||||
{
|
||||
HashMap<String, Entry> entries = EntryRegistry.entries.get(category);
|
||||
List<String> nameList = entryOrder.get(category);
|
||||
|
||||
ArrayList<Entry> list = new ArrayList<Entry>();
|
||||
|
||||
for(String str : nameList)
|
||||
{
|
||||
list.add(entries.get(str));
|
||||
}
|
||||
|
||||
Object[] entriesList = list.toArray();
|
||||
Entry[] entryList = new Entry[entriesList.length];
|
||||
|
||||
for(int i=0; i<entriesList.length; i++)
|
||||
{
|
||||
entryList[i] = (Entry)(entriesList[i]);
|
||||
}
|
||||
|
||||
return entryList;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue