use of betterquesting.api2.client.gui.resources.textures.SimpleTexture in project BetterQuesting by Funwayguy.
the class GuiHome method initPanel.
@Override
public void initPanel() {
super.initPanel();
PEventBroadcaster.INSTANCE.register(this, PEventButton.class);
ResourceLocation homeGui = new ResourceLocation(QuestSettings.INSTANCE.getProperty(NativeProps.HOME_IMAGE));
IGuiTexture homeSplashBG = new SimpleTexture(homeGui, new GuiRectangle(0, 0, 256, 128));
IGuiTexture homeSplashTitle = new SimpleTexture(homeGui, new GuiRectangle(0, 128, 256, 128)).maintainAspect(true);
float ancX = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_ANC_X);
float ancY = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_ANC_Y);
int offX = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_OFF_X);
int offY = QuestSettings.INSTANCE.getProperty(NativeProps.HOME_OFF_Y);
// Background panel
CanvasTextured bgCan = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture());
this.addPanel(bgCan);
// Inner canvas bounds
CanvasEmpty inCan = new CanvasEmpty(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(16, 16, 16, 16), 0));
bgCan.addPanel(inCan);
CanvasTextured splashCan = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 32), 0), homeSplashBG);
inCan.addPanel(splashCan);
CanvasTextured splashTitle = new CanvasTextured(new GuiTransform(new Vector4f(ancX, ancY, ancX, ancY), new GuiPadding(offX, offY, -256 - offX, -128 - offY), 0), homeSplashTitle);
splashCan.addPanel(splashTitle);
PanelButton btnExit = new PanelButton(new GuiTransform(new Vector4f(0F, 1F, 0.25F, 1F), new GuiPadding(0, -32, 0, 0), 0), 0, I18n.format("betterquesting.home.exit"));
inCan.addPanel(btnExit);
PanelButton btnQuests = new PanelButton(new GuiTransform(new Vector4f(0.25F, 1F, 0.5F, 1F), new GuiPadding(0, -32, 0, 0), 0), 1, I18n.format("betterquesting.home.quests"));
inCan.addPanel(btnQuests);
PanelButton btnParty = new PanelButton(new GuiTransform(new Vector4f(0.5F, 1F, 0.75F, 1F), new GuiPadding(0, -32, 0, 0), 0), 2, I18n.format("betterquesting.home.party"));
inCan.addPanel(btnParty);
PanelButton btnTheme = new PanelButton(new GuiTransform(new Vector4f(0.75F, 1F, 1F, 1F), new GuiPadding(0, -32, 0, 0), 0), 3, I18n.format("betterquesting.home.theme"));
inCan.addPanel(btnTheme);
if (QuestingAPI.getAPI(ApiReference.SETTINGS).canUserEdit(mc.player)) {
PanelButton btnEdit = new PanelButton(new GuiTransform(GuiAlign.TOP_LEFT, new GuiPadding(0, 0, -16, -16), 0), 4, "").setIcon(PresetIcon.ICON_GEAR.getTexture());
inCan.addPanel(btnEdit);
}
}
use of betterquesting.api2.client.gui.resources.textures.SimpleTexture in project BetterQuesting by Funwayguy.
the class CanvasQuestLine method setQuestLine.
/**
* Loads in quests and connecting lines
* @param line The quest line to load
*/
public void setQuestLine(IQuestLine line) {
// Rest contents
this.getAllPanels().clear();
if (line == null) {
return;
}
EntityPlayer player = Minecraft.getMinecraft().player;
UUID pid = QuestingAPI.getQuestingUUID(player);
String bgString = line.getProperties().getProperty(NativeProps.BG_IMAGE);
if (bgString != null && bgString.length() > 0) {
ResourceLocation bgRes = new ResourceLocation(bgString);
int bgSize = line.getProperties().getProperty(NativeProps.BG_SIZE);
this.addPanel(new PanelGeneric(new GuiRectangle(0, 0, bgSize, bgSize), new SimpleTexture(bgRes, new GuiRectangle(0, 0, 256, 256))));
}
// Used later to center focus the quest line within the window
boolean flag = false;
int minX = 0;
int minY = 0;
int maxX = 0;
int maxY = 0;
HashMap<Integer, PanelButtonStorage<IQuest>> questBtns = new HashMap<>();
for (IQuestLineEntry qle : line.getAllValues()) {
int id = line.getKey(qle);
IQuest quest = QuestDatabase.INSTANCE.getValue(id);
if (quest == null || !isQuestShown(quest, pid)) {
continue;
}
EnumQuestState qState = quest.getState(pid);
IGuiTexture txFrame = null;
IGuiColor txIconCol = null;
boolean main = quest.getProperties().getProperty(NativeProps.MAIN);
switch(qState) {
case LOCKED:
txFrame = main ? PresetTexture.QUEST_MAIN_0.getTexture() : PresetTexture.QUEST_NORM_0.getTexture();
txIconCol = PresetColor.QUEST_ICON_LOCKED.getColor();
break;
case UNLOCKED:
txFrame = main ? PresetTexture.QUEST_MAIN_1.getTexture() : PresetTexture.QUEST_NORM_1.getTexture();
txIconCol = PresetColor.QUEST_ICON_UNLOCKED.getColor();
break;
case UNCLAIMED:
txFrame = main ? PresetTexture.QUEST_MAIN_2.getTexture() : PresetTexture.QUEST_NORM_2.getTexture();
txIconCol = PresetColor.QUEST_ICON_PENDING.getColor();
break;
case COMPLETED:
txFrame = main ? PresetTexture.QUEST_MAIN_3.getTexture() : PresetTexture.QUEST_NORM_3.getTexture();
txIconCol = PresetColor.QUEST_ICON_COMPLETE.getColor();
break;
}
IGuiRect rect = new GuiRectangle(qle.getPosX(), qle.getPosY(), qle.getSize(), qle.getSize());
PanelButtonStorage<IQuest> paBtn = new PanelButtonStorage<>(rect, buttonId, "", quest);
paBtn.setTextures(new GuiTextureColored(txFrame, txIconCol), new GuiTextureColored(txFrame, txIconCol), new GuiTextureColored(txFrame, txIconCol));
paBtn.setIcon(new ItemTexture(quest.getItemIcon()), 4);
paBtn.setTooltip(quest.getTooltip(player));
this.addPanel(paBtn);
questBtns.put(id, paBtn);
if (!flag) {
minX = rect.getX();
minY = rect.getY();
maxX = minX + rect.getWidth();
maxY = minY + rect.getHeight();
flag = true;
} else {
minX = Math.min(minX, rect.getX());
minY = Math.min(minY, rect.getY());
maxX = Math.max(maxX, rect.getX() + rect.getWidth());
maxY = Math.max(maxY, rect.getY() + rect.getHeight());
}
}
for (Entry<Integer, PanelButtonStorage<IQuest>> entry : questBtns.entrySet()) {
IQuest quest = entry.getValue().getStoredValue();
List<IQuest> reqList = quest.getPrerequisites();
if (reqList.size() <= 0) {
continue;
}
boolean main = quest.getProperties().getProperty(NativeProps.MAIN);
EnumQuestState qState = quest.getState(pid);
IGuiLine lineRender = null;
IGuiColor txLineCol = null;
switch(qState) {
case LOCKED:
lineRender = PresetLine.QUEST_LOCKED.getLine();
txLineCol = PresetColor.QUEST_LINE_LOCKED.getColor();
break;
case UNLOCKED:
lineRender = PresetLine.QUEST_UNLOCKED.getLine();
txLineCol = PresetColor.QUEST_LINE_UNLOCKED.getColor();
break;
case UNCLAIMED:
lineRender = PresetLine.QUEST_PENDING.getLine();
txLineCol = PresetColor.QUEST_LINE_PENDING.getColor();
break;
case COMPLETED:
lineRender = PresetLine.QUEST_COMPLETE.getLine();
txLineCol = PresetColor.QUEST_LINE_COMPLETE.getColor();
break;
}
for (IQuest req : reqList) {
int id = QuestDatabase.INSTANCE.getKey(req);
PanelButtonStorage<IQuest> parBtn = questBtns.get(id);
if (parBtn != null) {
PanelLine prLine = new PanelLine(parBtn.getTransform(), entry.getValue().getTransform(), lineRender, main ? 8 : 4, txLineCol, 1);
this.addPanel(prLine);
}
}
}
float frameW = getTransform().getWidth();
float frameH = getTransform().getHeight();
if (frameW <= 0 || frameH <= 0) {
return;
}
minX -= margin;
minY -= margin;
maxX += margin;
maxY += margin;
float scale = Math.min(frameW / (maxX - minX), frameH / (maxY - minY));
scale = MathHelper.clamp(scale, 0.25F, 2F);
this.setZoom(scale);
int scrollX = Math.round((maxX - minX) / 2F - (frameW / scale) / 2F);
int scrollY = Math.round((maxY - minY) / 2F - (frameH / scale) / 2F);
this.setScrollX(scrollX);
this.setScrollY(scrollY);
}
Aggregations