vito-Z80

Untitled

Jul 7th, 2018
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 6.11 KB | None | 0 0
  1. class GameSkin(private val data: GeneralData) {
  2.  
  3.     val skin = Skin()
  4.     private val fonts = data.fonts
  5.     private val atlas = data.atlas
  6.  
  7.     private val NPSmall = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
  8.  
  9.     fun create() {
  10.         createFonts()
  11.         createLabel()
  12.         createList()
  13.         textButton()
  14.         scrollPane()
  15.         createImageButton()
  16.     }
  17.  
  18.     private fun createFonts() {
  19.         skin.add(FONT_SMALL, fonts.screenFontSmall, BitmapFont::class.java)
  20.         skin.add(FONT_NORMAL, fonts.screenFontNormal, BitmapFont::class.java)
  21.         skin.add(FONT_LARGE, fonts.screenFontLarge, BitmapFont::class.java)
  22.     }
  23.  
  24.     private fun createTable() {
  25.         val table = Table()
  26.         table.background = NPSmall
  27.     }
  28.  
  29.     private fun createLabel() {
  30.         var label = Label.LabelStyle()
  31.         label.font = skin[FONT_NORMAL, BitmapFont::class.java]
  32.         label.fontColor = Color.WHITE
  33.         label.background = NPSmall
  34.         skin.add(LABEL_NORMAL, label, Label.LabelStyle::class.java)
  35.  
  36.         label = Label.LabelStyle()
  37.         label.font = skin[FONT_SMALL, BitmapFont::class.java]
  38.         label.fontColor = Color.WHITE
  39.         label.background = NPSmall
  40.         skin.add(LABEL_SMALL, label, Label.LabelStyle::class.java)
  41.  
  42.         label = Label.LabelStyle()
  43.         label.font = skin[FONT_LARGE, BitmapFont::class.java]
  44.         label.fontColor = Color.WHITE
  45.         label.background = NPSmall
  46.         skin.add(LABEL_LARGE, label, Label.LabelStyle::class.java)
  47.  
  48.         label = Label.LabelStyle()
  49.         label.font = skin[FONT_NORMAL, BitmapFont::class.java]
  50.         label.fontColor = Color.WHITE
  51. //        label.background = TextureRegionDrawable(TextureRegion(atlas.getRegion(RegionName.ILLUMINATION)))
  52.         skin.add(DEFAULT, label, Label.LabelStyle::class.java)
  53.     }
  54.  
  55. //    fontColorSelected: white
  56. //    fontColorUnselected: white
  57. //    selection: pressed
  58. //    background: list
  59.  
  60.     private fun createList() {
  61.         var list = List.ListStyle()
  62.         list.font = getFont(FONT_SMALL)
  63.         list.fontColorSelected = Color.WHITE
  64.         list.fontColorUnselected = Color.WHITE
  65.         list.background = NPSmall
  66.         list.selection = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(0f, 0f, 0f, 0f))
  67.         skin.add(DEFAULT, list, List.ListStyle::class.java)
  68.  
  69.         list = List.ListStyle()
  70.         list.font = getFont(FONT_NORMAL)
  71. //        list.font.data.scale(0.2f)
  72.         list.fontColorSelected = Color.WHITE
  73.         list.fontColorUnselected = Color.WHITE
  74.         list.background = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_MENU), 18, 16, 16, 15))
  75.         list.selection = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(0f, 0f, 0f, 0f))
  76.         skin.add(NORMAL, list, List.ListStyle::class.java)
  77.     }
  78.  
  79.     private fun getFont(name: String): BitmapFont = skin[name, BitmapFont::class.java]
  80.  
  81.     private fun textTooltip() {
  82.         val ttt = TextTooltip.TextTooltipStyle()
  83.         ttt.label = skin[LABEL_NORMAL, Label.LabelStyle::class.java]
  84.         ttt.wrapWidth = 300f
  85.         ttt.background = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_MENU), 18, 16, 16, 15))
  86.         skin.add(TEXT_TOOLTIP, ttt, TextTooltip.TextTooltipStyle::class.java)
  87.     }
  88.  
  89.     private fun scrollPane() {
  90.         val scrollPane = ScrollPane.ScrollPaneStyle()
  91.         skin.add(DEFAULT, scrollPane, ScrollPane.ScrollPaneStyle::class.java)
  92.     }
  93.  
  94.     private fun textButton() {
  95.         var textButtonStyle = TextButton.TextButtonStyle()
  96.         var drawable = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
  97.         textButtonStyle.font = skin[FONT_SMALL, BitmapFont::class.java]
  98.         textButtonStyle.up = drawable
  99.         textButtonStyle.checkedOffsetX = 1f
  100.         textButtonStyle.checkedOffsetY = -1f
  101.         textButtonStyle.fontColor = Color.WHITE
  102.         textButtonStyle.checkedFontColor = Color.GREEN
  103.  
  104. //        textButtonStyle.checkedFontColor = Color.ORANGE
  105. //        textButtonStyle.checkedOverFontColor = Color.BLACK
  106.         textButtonStyle.disabledFontColor = Color.RED
  107.         skin.add(TEXT_BUTTON_STYLE_SMALL, textButtonStyle, TextButton.TextButtonStyle::class.java)
  108.         textButtonStyle = TextButton.TextButtonStyle()
  109.         textButtonStyle.pressedOffsetY = -1f
  110.         textButtonStyle.pressedOffsetX = 1f
  111.         textButtonStyle.up = NinePatchDrawable(NinePatch(atlas.getRegion(RegionName.NINE_PATCH_BUTTON_SMALL), 3, 3, 3, 3))
  112.         textButtonStyle.font = skin.getFont(FONT_NORMAL)
  113.         textButtonStyle.downFontColor = Color.GREEN
  114.         textButtonStyle.fontColor = Color.WHITE
  115.         skin.add(TEXT_BUTTON_STYLE_NORMAL, textButtonStyle, TextButton.TextButtonStyle::class.java)
  116.     }
  117.  
  118.  
  119.     private fun createImageButton() {
  120.         val iButton = ImageButton.ImageButtonStyle()
  121. //        iButton.up = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
  122.         iButton.imageDown = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
  123.         iButton.imageUp = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON))
  124.         iButton.imageChecked = TextureRegionDrawable(atlas.getRegion(RegionName.PAUSE_IMAGE_BUTTON)).tint(Color(1f, 1f, 1f, 0.8f))
  125.         skin.add(DEFAULT, iButton, ImageButton.ImageButtonStyle::class.java)
  126.     }
  127.  
  128.  
  129.     private fun selectBox() {
  130.         val box = SelectBox.SelectBoxStyle()
  131.         box.backgroundOpen = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION)).tint(Color(1f, 1f, 1f, 0.7f))
  132.         box.backgroundOver = TextureRegionDrawable(atlas.getRegion(RegionName.ILLUMINATION))
  133.         box.font = skin.getFont(FONT_SMALL)
  134.         box.fontColor = Color.GREEN
  135.         box.disabledFontColor = Color.WHITE
  136.         box.listStyle = skin[LIST_SMALL, List.ListStyle::class.java]
  137.         box.scrollStyle = skin[SCROLL_PANE, ScrollPane.ScrollPaneStyle::class.java]
  138.         skin.add(DEFAULT, box, SelectBox.SelectBoxStyle::class.java)
  139.     }
  140.  
  141.     fun dispose() = skin.dispose()
  142.  
  143. }
Advertisement
Add Comment
Please, Sign In to add comment