Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameSkin(private val data: GeneralData) {
- val skin = Skin()
- private val fonts = data.fonts
- private val atlas = data.atlas
- private val NPSmall = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
- fun create() {
- createFonts()
- createLabel()
- createList()
- textButton()
- scrollPane()
- createImageButton()
- }
- private fun createFonts() {
- skin.add(FONT_SMALL, fonts.screenFontSmall, BitmapFont::class.java)
- skin.add(FONT_NORMAL, fonts.screenFontNormal, BitmapFont::class.java)
- skin.add(FONT_LARGE, fonts.screenFontLarge, BitmapFont::class.java)
- }
- private fun createTable() {
- val table = Table()
- table.background = NPSmall
- }
- private fun createLabel() {
- var label = Label.LabelStyle()
- label.font = skin[FONT_NORMAL, BitmapFont::class.java]
- label.fontColor = Color.WHITE
- label.background = NPSmall
- skin.add(LABEL_NORMAL, label, Label.LabelStyle::class.java)
- label = Label.LabelStyle()
- label.font = skin[FONT_SMALL, BitmapFont::class.java]
- label.fontColor = Color.WHITE
- label.background = NPSmall
- skin.add(LABEL_SMALL, label, Label.LabelStyle::class.java)
- label = Label.LabelStyle()
- label.font = skin[FONT_LARGE, BitmapFont::class.java]
- label.fontColor = Color.WHITE
- label.background = NPSmall
- skin.add(LABEL_LARGE, label, Label.LabelStyle::class.java)
- label = Label.LabelStyle()
- label.font = skin[FONT_NORMAL, BitmapFont::class.java]
- label.fontColor = Color.WHITE
- // label.background = TextureRegionDrawable(TextureRegion(atlas.getRegion(RegionName.ILLUMINATION)))
- skin.add(DEFAULT, label, Label.LabelStyle::class.java)
- }
- // fontColorSelected: white
- // fontColorUnselected: white
- // selection: pressed
- // background: list
- private fun createList() {
- var list = List.ListStyle()
- list.font = getFont(FONT_SMALL)
- list.fontColorSelected = Color.WHITE
- list.fontColorUnselected = Color.WHITE
- list.background = NPSmall
- list.selection = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(0f, 0f, 0f, 0f))
- skin.add(DEFAULT, list, List.ListStyle::class.java)
- list = List.ListStyle()
- list.font = getFont(FONT_NORMAL)
- // list.font.data.scale(0.2f)
- list.fontColorSelected = Color.WHITE
- list.fontColorUnselected = Color.WHITE
- list.background = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_MENU), 18, 16, 16, 15))
- list.selection = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(0f, 0f, 0f, 0f))
- skin.add(NORMAL, list, List.ListStyle::class.java)
- }
- private fun getFont(name: String): BitmapFont = skin[name, BitmapFont::class.java]
- private fun textTooltip() {
- val ttt = TextTooltip.TextTooltipStyle()
- ttt.label = skin[LABEL_NORMAL, Label.LabelStyle::class.java]
- ttt.wrapWidth = 300f
- ttt.background = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_MENU), 18, 16, 16, 15))
- skin.add(TEXT_TOOLTIP, ttt, TextTooltip.TextTooltipStyle::class.java)
- }
- private fun scrollPane() {
- val scrollPane = ScrollPane.ScrollPaneStyle()
- skin.add(DEFAULT, scrollPane, ScrollPane.ScrollPaneStyle::class.java)
- }
- private fun textButton() {
- var textButtonStyle = TextButton.TextButtonStyle()
- var drawable = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
- textButtonStyle.font = skin[FONT_SMALL, BitmapFont::class.java]
- textButtonStyle.up = drawable
- textButtonStyle.checkedOffsetX = 1f
- textButtonStyle.checkedOffsetY = -1f
- textButtonStyle.fontColor = Color.WHITE
- textButtonStyle.checkedFontColor = Color.GREEN
- // textButtonStyle.checkedFontColor = Color.ORANGE
- // textButtonStyle.checkedOverFontColor = Color.BLACK
- textButtonStyle.disabledFontColor = Color.RED
- skin.add(TEXT_BUTTON_STYLE_SMALL, textButtonStyle, TextButton.TextButtonStyle::class.java)
- textButtonStyle = TextButton.TextButtonStyle()
- textButtonStyle.pressedOffsetY = -1f
- textButtonStyle.pressedOffsetX = 1f
- textButtonStyle.up = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
- textButtonStyle.font = skin.getFont(FONT_NORMAL)
- textButtonStyle.downFontColor = Color.GREEN
- textButtonStyle.fontColor = Color.WHITE
- skin.add(TEXT_BUTTON_STYLE_NORMAL, textButtonStyle, TextButton.TextButtonStyle::class.java)
- }
- private fun createImageButton() {
- val iButton = ImageButton.ImageButtonStyle()
- // iButton.up = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
- iButton.imageDown = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
- iButton.imageUp = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
- iButton.imageChecked = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON)).tint(Color(1f, 1f, 1f, 0.8f))
- skin.add(DEFAULT, iButton, ImageButton.ImageButtonStyle::class.java)
- }
- private fun selectBox() {
- val box = SelectBox.SelectBoxStyle()
- box.backgroundOpen = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(1f, 1f, 1f, 0.7f))
- box.backgroundOver = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION))
- box.font = skin.getFont(FONT_SMALL)
- box.fontColor = Color.GREEN
- box.disabledFontColor = Color.WHITE
- box.listStyle = skin[LIST_SMALL, List.ListStyle::class.java]
- box.scrollStyle = skin[SCROLL_PANE, ScrollPane.ScrollPaneStyle::class.java]
- skin.add(DEFAULT, box, SelectBox.SelectBoxStyle::class.java)
- }
- fun dispose() = skin.dispose()
- }
Advertisement
Add Comment
Please, Sign In to add comment