/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
* Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name of Oracle Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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
* OWNER 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 whiteout;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
public class Env {
public-init var screenWidth: Integer;
public-init var screenHeight: Integer;
public def smallFont =
if (screenWidth < 320)
Font {size: 15}
else if (screenWidth < 450)
Font {size: 20}
else
Font {size: 30}
public def mediumFont =
if (screenWidth < 320)
Font {size: 20}
else if (screenWidth < 450)
Font {size: 40}
else
Font {size: 50}
public def bigFont =
if (screenWidth < 320)
Font {size: 30}
else if (screenWidth < 450)
Font {size: 60}
else
Font {size: 70}
def resetSize = Text {
content: "Reset"
font: smallFont
};
public def blueButtonHeight = resetSize.layoutBounds.height + 8;
public def blueButtonWidth = resetSize.layoutBounds.width + 10;
public def nButtons = 5;
def gameButtonGapPercent = .1;
def nButtonsPlusGaps = nButtons * (1 + gameButtonGapPercent);
def countSize = Text {
content: "222"
font: mediumFont
}
public def controlWidth = if (blueButtonWidth > countSize.layoutBounds.width)
blueButtonWidth
else
countSize.layoutBounds.width;
public def isPortrait = if (screenWidth - controlWidth < screenHeight) true else false;
public def gameSize = if (isPortrait) {
var useableHeight = screenHeight - blueButtonHeight - 10;
if (useableHeight <= screenWidth) useableHeight else screenWidth;
} else {
var useableWidth = screenWidth - controlWidth - 10 ;
if (useableWidth <= screenHeight) useableWidth else screenHeight;
}
public def gameButtonSize = gameSize / (nButtonsPlusGaps + gameButtonGapPercent);
public def gameButtonGap = gameButtonSize * gameButtonGapPercent;
public def gameButtonStrokeWidth = if (gameButtonGap >= 4) 3 else .5 * gameButtonGap;
public def buttonX = if (isPortrait) gameButtonGap else gameSize + (screenWidth - gameSize - blueButtonWidth) / 2;
public def topMargin = gameButtonGap;
public def slateGrad = LinearGradient{
startX: 0
startY: 0
endX: 0
endY: 1
stops: [
Stop {offset: 0.0, color: Color.rgb(0x34, 0x34, 0x34)},
Stop {offset: 0.5, color: Color.rgb(0x55, 0x55, 0x55)},
Stop {offset: 1.0, color: Color.rgb(0x43, 0x43, 0x43)}
]
}
public def blueGrad = LinearGradient{
startX: 0
startY: 0
endX: 0
endY: 1
stops: [
Stop {offset: 0.0, color:Color.rgb(0, 0x33, 0xff)},
Stop {offset: 0.5, color:Color.rgb(0, 0x55, 0xff)},
Stop {offset: 1.0, color:Color.BLUE}
]
}
}