Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make gui scale configurable from python #458

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ protected void onMissionStarted()

if (missionBehaviour.lowLevelInputs) {
Minecraft.getMinecraft().gameSettings.hideGUI = false;
Minecraft.getMinecraft().gameSettings.guiScale = 2;
Minecraft.getMinecraft().gameSettings.guiScale = missionBehaviour.guiScale;
Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
} else {
// Disable the gui for the episode!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Logger;

import com.microsoft.Malmo.MissionHandlerInterfaces.IAudioProducer;
import com.microsoft.Malmo.MissionHandlerInterfaces.ICommandHandler;
Expand All @@ -37,7 +36,6 @@
import com.microsoft.Malmo.Schemas.AgentSection;
import com.microsoft.Malmo.Schemas.MissionInit;
import com.microsoft.Malmo.Schemas.ServerHandlers;
import com.microsoft.Malmo.Utils.TimeHelper;

/** Holder class for the various MissionHandler interfaces that together define the behaviour of the mission.<br>
*/
Expand All @@ -53,6 +51,7 @@ public class MissionBehaviour
public IPerformanceProducer performanceProducer = null;
public IWantToQuit quitProducer = null;
public boolean lowLevelInputs = false;
public Integer guiScale = null;

private String failedHandlers = "";

Expand Down Expand Up @@ -120,6 +119,7 @@ private void initAgent(MissionInit missionInit)
// TODO hack - low level inputs are read from first agent. Ideally they should be either agent-specific,
// or mission-level
lowLevelInputs = agents.get(0).getAgentStart().isLowLevelInputs() != null && agents.get(0).getAgentStart().isLowLevelInputs();
guiScale = agents.get(0).getAgentStart().getGuiScale();
}

public boolean addExtraHandlers(List<Object> handlers)
Expand Down
7 changes: 7 additions & 0 deletions minerl/Malmo/Schemas/Mission.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="GuiScale" type="xs:int" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Overrides default gui scale
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
Expand Down
2 changes: 1 addition & 1 deletion minerl/herobraine/env_specs/human_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def create_monitors(self) -> List[TranslationHandler]:
return [] # No monitors by default!o

def create_agent_start(self) -> List[Handler]:
return [handlers.LowLevelInputsAgentStart()]
return [handlers.LowLevelInputsAgentStart(), handlers.GuiScale(5)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the different defaults 5.0 vs 4.0 in here and below?

10 changes: 10 additions & 0 deletions minerl/herobraine/hero/handlers/agent/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,13 @@ def to_string(self) -> str:

def xml_template(self) -> str:
return "<LowLevelInputs>true</LowLevelInputs>"

class GuiScale(Handler):
def __init__(self, gui_scale=4.0):
self.gui_scale = gui_scale

def to_string(self) -> str:
return "gui_scale"

def xml_template(self) -> str:
return "<GuiScale>{{gui_scale}}</GuiScale>"