You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.2 KiB
108 lines
3.2 KiB
11 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
/**
|
||
|
* Defines visual appearance of a Page.
|
||
11 years ago
|
* The Game.activePageStyle property controls the visual appearance of the displayed Page
|
||
11 years ago
|
*/
|
||
|
public class PageStyle : MonoBehaviour
|
||
|
{
|
||
|
// The font size for title, say and option text is calculated by multiplying the screen height
|
||
|
// by the corresponding font scale. Text appears the same size across all device resolutions.
|
||
|
|
||
11 years ago
|
/// Header font size as a fraction of screen height.
|
||
|
public float headerFontScale = 1f / 20f;
|
||
11 years ago
|
|
||
|
/// Say font size as a fraction of screen height.
|
||
|
public float sayFontScale = 1f / 25f;
|
||
|
|
||
11 years ago
|
/// Header font size as a fraction of screen height.
|
||
|
public float footerFontScale = 1f / 20f;
|
||
|
|
||
11 years ago
|
/// Option font size as a fraction of screen height.
|
||
|
public float optionFontScale = 1f / 25f;
|
||
|
|
||
11 years ago
|
/// Style for header text
|
||
|
public GUIStyle headerStyle;
|
||
|
|
||
|
/// Style for header text
|
||
|
public GUIStyle footerStyle;
|
||
11 years ago
|
|
||
|
/// Style for say text
|
||
|
public GUIStyle sayStyle;
|
||
|
|
||
|
/// Style for option text
|
||
|
public GUIStyle optionStyle;
|
||
|
|
||
11 years ago
|
/// Style for option text (alternate rows)
|
||
|
public GUIStyle optionAlternateStyle;
|
||
|
|
||
11 years ago
|
/// Style for text box
|
||
|
public GUIStyle boxStyle;
|
||
|
|
||
11 years ago
|
/**
|
||
11 years ago
|
* Returns the style for Header text.
|
||
|
* Overrides the font size to compensate for varying device resolution.
|
||
|
* Font size is calculated as a fraction of the current screen height.
|
||
|
*/
|
||
|
public GUIStyle GetScaledHeaderStyle()
|
||
|
{
|
||
|
GUIStyle style = new GUIStyle(headerStyle);
|
||
|
style.fontSize = Mathf.RoundToInt((float)Screen.height * headerFontScale);
|
||
|
return style;
|
||
|
}
|
||
|
|
||
|
/**
|
||
11 years ago
|
* Returns the style for SetFooter text.
|
||
11 years ago
|
* Overrides the font size to compensate for varying device resolution.
|
||
11 years ago
|
* Font size is calculated as a fraction of the current screen height.
|
||
|
*/
|
||
11 years ago
|
public GUIStyle GetScaledFooterStyle()
|
||
11 years ago
|
{
|
||
11 years ago
|
GUIStyle style = new GUIStyle(footerStyle);
|
||
|
style.fontSize = Mathf.RoundToInt((float)Screen.height * footerFontScale);
|
||
11 years ago
|
return style;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the style for Say text.
|
||
11 years ago
|
* Overrides the font size to compensate for varying device resolution.
|
||
11 years ago
|
* Font size is calculated as a fraction of the current screen height.
|
||
|
*/
|
||
|
public GUIStyle GetScaledSayStyle()
|
||
|
{
|
||
|
GUIStyle style = new GUIStyle(sayStyle);
|
||
|
style.fontSize = Mathf.RoundToInt((float)Screen.height * sayFontScale);
|
||
|
return style;
|
||
|
}
|
||
|
|
||
|
/**
|
||
11 years ago
|
* Returns the style for Option buttons.
|
||
|
* Overrides the font size to compensate for varying device resolution.
|
||
11 years ago
|
* Font size is calculated as a fraction of the current screen height.
|
||
|
*/
|
||
|
public GUIStyle GetScaledOptionStyle()
|
||
|
{
|
||
11 years ago
|
GUIStyle style;
|
||
|
style = new GUIStyle(optionStyle);
|
||
|
style.fontSize = Mathf.RoundToInt((float)Screen.height * optionFontScale);
|
||
|
return style;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the alternate style for Option buttons.
|
||
|
* This can be used to create alternating color rows.
|
||
|
* Overrides the font size to compensate for varying device resolution.
|
||
|
* Font size is calculated as a fraction of the current screen height.
|
||
|
*/
|
||
|
public GUIStyle GetScaledOptionAlternateStyle()
|
||
|
{
|
||
|
GUIStyle style;
|
||
|
style = new GUIStyle(optionAlternateStyle);
|
||
11 years ago
|
style.fontSize = Mathf.RoundToInt((float)Screen.height * optionFontScale);
|
||
|
return style;
|
||
11 years ago
|
}
|
||
|
}
|
||
|
}
|