×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Biblioteca] C4u
[Biblioteca] C4u
Bomboffkiler
« Citoyen »
1633902840000
    • Bomboffkiler#0000
    • Profil
    • Derniers messages
    • Tribu
#1
  0
C4U

C4U é uma camada em cima de métodos como ui.addTextArea e tfm.exec.addImage, produzindo objetos chamados componentes. Esse é um sucessor de TextAreaShop.

Código fonte

c4u.lua

Otimizado: c4u.min.lua

Instalação

Cole o código fonte da biblioteca no seu código. Registre os seguintes eventos:

Code Lua

1
2
3
function eventPlayerLeft(name)
c4u.internals.playerLeft(name)
end

Exemplos

Code Lua

1
2
3
4
5
6
7
8
local ta = c4u.textarea():setText('Welcome!')
:setPos(200, 200):setSize(100, 100):setBackgroundColor(0x444444):setBorderColor(0xffffff)
:addChild(
-- a posição de um componente filho é relativa a de seu parente
c4u.textarea():setText('foo'):setSize(100, 100):setPos(100, 100))
ta:render()
-- ta:unrender()
-- ta:updateRenderedText(): atualiza HTML
https://i.imgur.com/tP076op.png

Crie seus próprios subtipos

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mycomponent_t = c4u.component.subtype()

function mycomponent_t:new()
local r = c4u.component.subtype_instance(self)
-- defina campos internos aqui:
-- r._algumCampo = valorInicial
r._rendered = false
return r
end

function mycomponent_t:isRendered()
return self._rendered
end

function mycomponent_t:render()
if self:isRendered() then
self:unrender()
end
-- renderize aqui
self._rendered = true
self:renderChildren()
end

function mycomponent_t:unrender()
if not self:isRendered() then
return
end
-- desfaça a renderização aqui
self._rendered = false
self:unrenderChildren()
end

Referência

  • c4u.component:typeOf ()

  • c4u.component:target ()

  • c4u.component:setTarget ( v )

  • c4u.component:parent ()

  • c4u.component:children ()

  • c4u.component:addChild ( child )

  • c4u.component:removeChild ( child )

  • c4u.component:setPos ( x, y )

  • c4u.component:x ()

  • c4u.component:setX ( x )

  • c4u.component:y ()

  • c4u.component:setY ( y )

  • c4u.component:fixedPos ()

  • c4u.component:setFixedPos ( hasFixedPos )

  • c4u.component:globalX ()

  • c4u.component:globalY ()

  • c4u.component:isRendered ()

  • c4u.component:render ()

  • c4u.component:renderChildren ()

  • c4u.component:unrender ()

  • c4u.component:unrenderChildren ()

  • c4u.component:inheritTarget ()

  • c4u.component:inheritFixedPos ()

  • c4u.textarea ()

  • c4u.textarea:setSize ( width, height )

  • c4u.textarea:text ()

  • c4u.textarea:setText ( text )

  • c4u.textarea:width ()

  • c4u.textarea:setWidth ( width )

  • c4u.textarea:height ()

  • c4u.textarea:setHeight ( height )

  • c4u.textarea:backgroundColor ()

  • c4u.textarea:setBackgroundColor ( colorCode )

  • c4u.textarea:borderColor ()

  • c4u.textarea:setBorderColor ( colorCode )

  • c4u.textarea:backgroundAlpha ()

  • c4u.textarea:setBackgroundAlpha ( zeroToOneAlpha )

  • c4u.textarea:updateRenderedText ()

  • c4u.image ()

  • c4u.image:source ()

  • c4u.image:setSource ( imageId )

  • c4u.image:scaleX ()

  • c4u.image:setScaleX ( scaleX )

  • c4u.image:scaleY ()

  • c4u.image:setScaleY ( scaleY )

  • c4u.image:angle ()

  • c4u.image:setAngle ( degrees )

  • c4u.image:alpha ()

  • c4u.image:setAlpha ( zeroToOneAlpha )

  • c4u.image:anchorX ()

  • c4u.image:setAnchorX ( anchorX )

  • c4u.image:anchorY ()

  • c4u.image:setAnchorY ( anchorY )

Dernière modification le 1678104540000
Gamedroit
« Citoyen »
1634140500000
    • Gamedroit#3347
    • Profil
    • Derniers messages
    • Tribu
#2
  1
Wow, gostei da biblioteca, torna tudo mais fácil e diminui a quantidade de cálculo que você precisa fazer para posicionar os elementos na tela.
Bomboffkiler
« Citoyen »
1634145840000
    • Bomboffkiler#0000
    • Profil
    • Derniers messages
    • Tribu
#3
  0
Gamedroit a dit :
Wow, gostei da biblioteca, torna tudo mais fácil e diminui a quantidade de cálculo que você precisa fazer para posicionar os elementos na tela.

Obrigado pelo feedback!
Bolodefchoco
« Sénateur »
1634153820000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#4
  0
Seria melhor usar camelCase
Bomboffkiler
« Citoyen »
1634154480000
    • Bomboffkiler#0000
    • Profil
    • Derniers messages
    • Tribu
#5
  0
Bolodefchoco a dit :
Seria melhor usar camelCase

Pelo que eu entendo, Lua segue as convenções do C. JavaScript sim que usa camelCase e CamelCase para tipos/módulos.

No caso, quando uma referência léxica é ambígua, o tipo/módulo tem que ser prefixado com t_ ou ns_.. No BASIC referências léxicas tem a mesma situação já que a linguagem é de caso-insensitivo.

Dernière modification le 1634159160000
Bolodefchoco
« Sénateur »
1634172240000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#6
  0
Considerando que a convenção utilizada pela API é camelCase e que você fez algo para manipulá-la, acredito que faça mais sentido utilizar tal. É também muito mais legível, principalmente em editores sem color highlight como é o caso do fórum e da interface do /lua
Bomboffkiler
« Citoyen »
1634210520000
    • Bomboffkiler#0000
    • Profil
    • Derniers messages
    • Tribu
#7
  0
Bolodefchoco a dit :
Considerando que a convenção utilizada pela API é camelCase e que você fez algo para manipulá-la, acredito que faça mais sentido utilizar tal. É também muito mais legível, principalmente em editores sem color highlight como é o caso do fórum e da interface do /lua

Um exemplo são as funções tonumber(), tostring() e getmetatable()... Como pode ver são sneak-case e são standard do Lua. Só as do Transformice que utilizam camelCase.

EDIT: mudei as convenções conforme você falou.

Dernière modification le 1664053920000
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Biblioteca] C4u
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27