Constrain the display settings options

hi together



My Code inherits from SimpleGame and i use ALWAYS_SHOW_PROPS_DIALOG



Now i want to constrain the resolution settings in the Props Dialog. I want to avoid that somebody starts the application with less than 1024 width. how can i achieve that?



thx

i found this method in the com.jme.system.PropertiesDialog.java Class


private JComboBox setUpResolutionChooser() {
      String[] modes = { "640x480", "800x600", "1024x768", "1280x1024", "1600x1200" };
      JComboBox resolutionBox = new JComboBox(modes);

      resolutionBox.setSelectedItem(source.getWidth() + "x" + source.getHeight());

      return resolutionBox;
   }



can i just change the line

String[] modes = { "640x480", "800x600", "1024x768", "1280x1024", "1600x1200" };



or is there any better solution?

another problem is that i have more options to chose like 320x320. where are this one defined?

isn't it possible to define it in the properties file?

I would choose not to use SimpleGame for anything you're going to release.

I just wrote my own simple interface for setting the display settings as part of the game menu and turn the default properties window off.

That way you have complete control, and your settings can have the same look&feel as the rest of the game.

ok i think the bette choose is this method in propertiesdialog2


private static String[] getResolutions(DisplayMode[] modes) {
        ArrayList<String> resolutions = new ArrayList<String>(16);
        for (int i = 0; i < modes.length; i++) {
           
            String res = modes[i].getWidth() + " x " + modes[i].getHeight();
            if (!resolutions.contains(res))
                resolutions.add(res);
        }
       
        String[] res = new String[resolutions.size()];
        resolutions.toArray(res);
        return res;
    }



i choosed it in:

private static String[] getResolutions(DisplayMode[] modes) {
        ArrayList<String> resolutions = new ArrayList<String>(16);
        for (int i = 0; i < modes.length; i++) {
           if (modes[i].getWidth() >= 1024) {
            String res = modes[i].getWidth() + " x " + modes[i].getHeight();
            if (!resolutions.contains(res))
                resolutions.add(res);
        }
        }
        String[] res = new String[resolutions.size()];
        resolutions.toArray(res);
        return res;
    }



buzt nevertheless i doesn't work :(
can anybody help?

you're absolutely right but i think now it's to late for me to change because i already wrote a lot of code

ok i got a new idea.



i could use a properties file do define the settings of the window. then i use NEVER_SHOW_PROPS Dialog and create in the window a fenggui menu which ask the user to chose his window settings. after that i use the method recreate to set the window to the right sizes and start to draw my application. that should work shouldn't it?

yep.

Don't think so. I do something similar, just starting from BaseGame instead of SimpleGame.

Probably worth checking SimpleGame doesn't do anything that might conflict with it but afaik it should be fine.

are there any possible problems why i shouldn't do that?

it shouldnt be a problem. i made it this way:


protected void simpleInitGame() {
      CP_Setting settings = new CP_Setting(this);
      settings.drawSettings();
      inputSettings = settings.getMenuHandler();
      dispSettings = settings.getFDisplay();
      simpleUpdate();
   }



but then the window is draw but i can't see the fengGUI menu. does anybody knows why?

this problem i solved.



know can i just use an array of resolutions or should i besser use the GraphicsEnvorinoment…() call which returns some supported DisplayModes?



that would be a loat of more work

Sebastian23 said:

or should i besser use the GraphicsEnvorinoment....() call which returns some supported DisplayModes?

Definitely. How else could you be sure that the display modes you are offering are even supported on the target system?

hmm don't know :wink:



but with dept, resolution, refreshrate and fullscreen there are thousands of combinations possible

ok i also solved this problem. but now there is a new one.



if i use recreate window, the window is if not drawn on fullscreen mode, not in the middle of the monitor but on a edge. additionally i think the lines aren't draw parallel but a little bit distorted. what could cause that behaviour?

i also solved this problem by adding a few line to the lwjglDisplaySystem class. Does anybody see there any problem?

Sebastian23 said:

i also solved this problem by adding a few line to the lwjglDisplaySystem class. Does anybody see there any problem?

:? But of course that depends greatly on what lines you addes to that class. 

Also, you should probably pick up the habit to start a new thread for a new topic, that way the threads will be a lot easier to read and navigate.

yes that's true. i made a feature request on http://www.jmonkeyengine.com/jmeforum/index.php?topic=9787.0