forked from Kolyah35/minecraft-pe-0.6.1
Made some changes to the GUI scale slider.
Should be waaaaaaay better now
This commit is contained in:
@@ -1160,12 +1160,13 @@ void Minecraft::setSize(int w, int h) {
|
||||
|
||||
// determine gui scale, optionally overriding auto
|
||||
if (guiScale != 0) {
|
||||
// manual selection: 1->small, 2->normal, 3->large, 4->larger
|
||||
// manual selection: 1->small, 2->medium, 3->large, 4->larger, 5->largest
|
||||
switch (guiScale) {
|
||||
case 1: Gui::GuiScale = 2.0f; break;
|
||||
case 2: Gui::GuiScale = 3.0f; break;
|
||||
case 3: Gui::GuiScale = 4.0f; break;
|
||||
case 4: Gui::GuiScale = 5.0f; break; // bigger than large
|
||||
case 4: Gui::GuiScale = 5.0f; break;
|
||||
case 5: Gui::GuiScale = 6.0f; break;
|
||||
default: Gui::GuiScale = 1.0f; break; // auto
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -65,7 +65,7 @@ void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
|
||||
OptionsItem* item = new OptionsItem(itemLabel, element);
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
@@ -77,7 +77,7 @@ void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(itemLabel, element);
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(itemLabel, element);
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(itemLabel, element);
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(itemLabel, element);
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "OptionsItem.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../../locale/I18n.h"
|
||||
#include "../../../util/Mth.h"
|
||||
OptionsItem::OptionsItem( std::string label, GuiElement* element )
|
||||
OptionsItem::OptionsItem( OptionId optionId, std::string label, GuiElement* element )
|
||||
: GuiElementContainer(false, true, 0, 0, 24, 12),
|
||||
label(label) {
|
||||
m_optionId(optionId),
|
||||
m_label(label) {
|
||||
addChild(element);
|
||||
}
|
||||
|
||||
@@ -19,6 +21,22 @@ void OptionsItem::setupPositions() {
|
||||
|
||||
void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
int yOffset = (height - 8) / 2;
|
||||
minecraft->font->draw(label, (float)x, (float)y + yOffset, 0x909090, false);
|
||||
std::string text = m_label;
|
||||
if (m_optionId == OPTIONS_GUI_SCALE) {
|
||||
int value = minecraft->options.getIntValue(OPTIONS_GUI_SCALE);
|
||||
std::string scaleText;
|
||||
switch (value) {
|
||||
case 0: scaleText = I18n::get("options.guiScale.auto"); break;
|
||||
case 1: scaleText = I18n::get("options.guiScale.small"); break;
|
||||
case 2: scaleText = I18n::get("options.guiScale.medium"); break;
|
||||
case 3: scaleText = I18n::get("options.guiScale.large"); break;
|
||||
case 4: scaleText = I18n::get("options.guiScale.larger"); break;
|
||||
case 5: scaleText = I18n::get("options.guiScale.largest"); break;
|
||||
default: scaleText = I18n::get("options.guiScale.auto"); break;
|
||||
}
|
||||
text += ": " + scaleText;
|
||||
}
|
||||
|
||||
minecraft->font->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
|
||||
super::render(minecraft, xm, ym);
|
||||
}
|
||||
@@ -15,12 +15,13 @@ class OptionsItem: public GuiElementContainer
|
||||
{
|
||||
typedef GuiElementContainer super;
|
||||
public:
|
||||
OptionsItem(std::string label, GuiElement* element);
|
||||
OptionsItem(OptionId optionId, std::string label, GuiElement* element);
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
void setupPositions();
|
||||
|
||||
private:
|
||||
std::string label;
|
||||
OptionId m_optionId;
|
||||
std::string m_label;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsItem_H__*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../renderer/Textures.h"
|
||||
#include "../Screen.h"
|
||||
#include "../../../locale/I18n.h"
|
||||
#include "../../../util/Mth.h"
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
@@ -21,7 +22,7 @@ void Slider::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
|
||||
if (m_numSteps > 2) {
|
||||
int stepDistance = barWidth / (m_numSteps-1);
|
||||
for(int a = 0; a <= m_numSteps; ++a) {
|
||||
for(int a = 0; a < m_numSteps; ++a) {
|
||||
int renderSliderStepPosX = xSliderStart + a * stepDistance + 1;
|
||||
fill(renderSliderStepPosX - 1, ySliderStart - 2, renderSliderStepPosX + 1, ySliderEnd + 2, 0xff606060);
|
||||
}
|
||||
@@ -64,15 +65,20 @@ SliderFloat::SliderFloat(Minecraft* minecraft, OptionId option)
|
||||
SliderInt::SliderInt(Minecraft* minecraft, OptionId option)
|
||||
: Slider(option), m_option(dynamic_cast<OptionInt*>(minecraft->options.getOpt(option)))
|
||||
{
|
||||
m_numSteps = m_option->getMax() - m_option->getMin();
|
||||
m_numSteps = m_option->getMax() - m_option->getMin() + 1;
|
||||
m_percentage = float(m_option->get() - m_option->getMin()) / (m_numSteps-1);
|
||||
}
|
||||
|
||||
void SliderInt::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
Slider::render(minecraft, xm, ym);
|
||||
}
|
||||
|
||||
void SliderInt::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
|
||||
Slider::mouseReleased(minecraft, x, y, buttonNum);
|
||||
|
||||
if (pointInside(x, y)) {
|
||||
int curStep = Mth::floor(m_percentage * (m_numSteps-1));
|
||||
int curStep = int(m_percentage * (m_numSteps-1) + 0.5f);
|
||||
curStep = Mth::clamp(curStep + m_option->getMin(), m_option->getMin(), m_option->getMax());
|
||||
m_percentage = float(curStep - m_option->getMin()) / (m_numSteps-1);
|
||||
|
||||
minecraft->options.set(m_optId, curStep);
|
||||
|
||||
@@ -38,6 +38,7 @@ class SliderInt : public Slider {
|
||||
public:
|
||||
SliderInt(Minecraft* minecraft, OptionId option);
|
||||
|
||||
virtual void render( Minecraft* minecraft, int xm, int ym ) override;
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) override;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user