Move the 765x503 constants to a Constants API class
This commit is contained in:
36
runelite-api/src/main/java/net/runelite/api/Constants.java
Normal file
36
runelite-api/src/main/java/net/runelite/api/Constants.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
public static final int GAME_FIXED_WIDTH = 765;
|
||||
public static final int GAME_FIXED_HEIGHT = 503;
|
||||
public static final Dimension GAME_FIXED_SIZE = new Dimension(GAME_FIXED_WIDTH, GAME_FIXED_HEIGHT);
|
||||
public static final double GAME_FIXED_ASPECT_RATIO = (double) GAME_FIXED_WIDTH / (double) GAME_FIXED_HEIGHT;
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.config;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import net.runelite.api.Constants;
|
||||
|
||||
@ConfigGroup(
|
||||
keyName = "runelite",
|
||||
@@ -40,7 +41,7 @@ public interface RuneLiteConfig extends Config
|
||||
)
|
||||
default Dimension gameSize()
|
||||
{
|
||||
return new Dimension(765, 503);
|
||||
return Constants.GAME_FIXED_SIZE;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
|
||||
@@ -27,22 +27,20 @@ package net.runelite.client.ui;
|
||||
import java.applet.Applet;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.JPanel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Constants;
|
||||
|
||||
@Slf4j
|
||||
final class ClientPanel extends JPanel
|
||||
{
|
||||
public static final int PANEL_WIDTH = 765, PANEL_HEIGHT = 503;
|
||||
|
||||
public ClientPanel(@Nullable Applet client)
|
||||
{
|
||||
setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setSize(Constants.GAME_FIXED_SIZE);
|
||||
setMinimumSize(Constants.GAME_FIXED_SIZE);
|
||||
setPreferredSize(Constants.GAME_FIXED_SIZE);
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(Color.black);
|
||||
|
||||
@@ -52,7 +50,7 @@ final class ClientPanel extends JPanel
|
||||
}
|
||||
|
||||
client.setLayout(null);
|
||||
client.setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
client.setSize(Constants.GAME_FIXED_SIZE);
|
||||
|
||||
client.init();
|
||||
client.start();
|
||||
|
||||
Reference in New Issue
Block a user