TR/guiCreateWindow: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Tag: Manual revert
 
(5 intermediate revisions by the same user not shown)
Line 8: Line 8:
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Gerekli Argümanlar===
[[Image:gui-window.png|frame|Example Window.]]
[[Image:gui-window.png|frame|Örnek Window.]]
*'''x:''' A float of the 2D x position of the GUI window on a player's screen. This is affected by the ''relative'' argument.
*'''x:''' Bir oyuncunun ekranında GUI penceresinin 2D x konumunun bir kayan nokta. Bu, ''relative'' argümandan etkilenir.
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.
*'''y:''' Bir oyuncunun ekranında GUI penceresinin 2B y konumunun bir şamandırası. Bu, ''relative'' argümandan etkilenir.
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.
*'''width:''' GUI penceresinin genişliği. Bu, ''relative'' argümandan etkilenir.
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.
*'''height:''' GUI penceresinin yüksekliği. Bu, ''relative'' argümandan etkilenir.
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.
*'''titleBarText:''' Pencerenin başlık çubuğunda görüntülenecek metin.
*'''relative:''' This is whether sizes and positioning are relative. If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].
*'''relative:''' Bu, boyutların ve konumlandırmanın göreceli olup olmadığıdır. Bu "doğru" ise, tüm x,y,width,height değişkenleri 0 ile 1 arasında olmalıdır ve boyutları/konumları ekran boyutunun bir bölümü olarak temsil eder. "Yanlış" ise, boyut ve koordinatlar müşterinin çözünürlüğüne bağlıdır ve [[guiGetScreenSize]] kullanılarak erişilebilir.


===Returns===
===Returns===
Returns a gui window element if it was created successfully, false otherwise.
Returns a gui window element if it was created successfully, false otherwise.


==Example==  
==Örnek==  
'''Example 1:''' This example creates a information window and adds two tabs to a "tabPanel" tabpanel, and adds some other gui elements to it.
'''Örnek 1:''' Bu örnek bir bilgi penceresi oluşturur ve bir "tabPanel" sekme paneline iki sekme ekler ve ona başka gui öğeleri ekler.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true )  -- create a window which has "Information" in the title bar.
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Bilgi", true )  -- başlık çubuğunda "Bilgi" olan bir pencere oluşturun.
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow )      -- create a tab panel which fills the whole window
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow )      -- tüm pencereyi dolduran bir sekme paneli oluşturun
local tabMap = guiCreateTab( "Map Information", tabPanel )                -- create a tab named "Map Information" on 'tabPanel'
local tabMap = guiCreateTab( "Harita Bilgileri", tabPanel )                -- 'tabPanel' üzerinde "Harita Bilgileri" adlı bir sekme oluşturun
local tabHelp = guiCreateTab( "Help", tabPanel )                          -- create another tab named "Help" on 'tabPanel'
local tabHelp = guiCreateTab( "Yardım", tabPanel )                          -- 'tabPanel' üzerinde "Yardım" adında başka bir sekme oluşturun


-- adds a label (text) to each tab
-- adds a label (text) to each tab
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap)
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "Bu, mevcut harita hakkında bilgidir", true, tabMap)
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp)
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "Bu, yardım mesajıdır.", true, tabHelp)
</syntaxhighlight>
</syntaxhighlight>


'''Example 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.
'''Örnek 2:''' Bu örnek, bir pencere, kılavuz listesi ve bir düğme ile tamamlanmış bir silah seçim ekranı oluşturur. Kullanıcılar bir av tüfeği veya makineli tüfek seçebilir. Pencere hareketli veya büyük değil.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--Setup some tables
--Bazı tablolar


shotguns = {
shotguns = {
Line 49: Line 49:


function setupWeaponSelection ( theResource )
function setupWeaponSelection ( theResource )
       -- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start
       -- alttaki getResourceRootElement(getThisResource()), yalnızca bu kaynak başlangıcında gui oluşturacağı anlamına gelir
       -- Create a window for our spawnscreen, with the title "Select your weapons".
       -- Açılma ekranımız için "Silahlarınızı seçin" başlıklı bir pencere oluşturun.
       spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )
       spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Silahlarınızı seçin", true )
       -- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function
       -- kullanıcının seçimlerini onaylamasına izin vermek için bir Tamam düğmesi oluşturun ve bunu onay Seçimi işlevine ekleyin
       spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )
       spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Tamam", true, spawnScreenMenu )
       -- ensure the user can't move or resize our spawnscreen.
       -- kullanıcının spawn ekranımızı hareket ettiremediğinden veya yeniden boyutlandıramadığından emin olun.
       guiWindowSetMovable ( spawnScreenMenu, false )
       guiWindowSetMovable ( spawnScreenMenu, false )
       guiWindowSetSizable ( spawnScreenMenu, false )
       guiWindowSetSizable ( spawnScreenMenu, false )
       -- create our gridlist, which fills up most of the window.
       -- pencerenin çoğunu dolduran kılavuz listemizi oluşturun.
       spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )
       spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )
       guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column
       guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- seçim modunun sütun başına bir olduğundan emin olun
       -- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns
       -- 2 set silahımız olduğu için av tüfeği için bir sütun ve makineli tüfek için bir sütun oluşturun.
       guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )
       guiGridListAddColumn ( spawnScreenGridList, "Tüfekler", 0.3 )
       guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )
       guiGridListAddColumn ( spawnScreenGridList, "Makineli tüfekler", 0.3 )
       -- next, we loop through our handguns table to add handgun items to the gridlist
       -- sonra, ızgara listesine tabanca öğeleri eklemek için tabanca tablomuzda dolaşıyoruz
       for key,weaponName in pairs(shotguns) do
       for key,weaponName in pairs(shotguns) do
             -- add a new row to our gridlist each time
             -- her seferinde ızgara listemize yeni bir satır ekleyin
             local row = guiGridListAddRow ( spawnScreenGridList )
             local row = guiGridListAddRow ( spawnScreenGridList )
             -- next, we set that row's text to the weapon name. Column is 1 since the "Shotguns" column was created first.
             -- sonra, o satırın metnini silah adına ayarladık. İlk olarak "Av Tüfeği" sütunu oluşturulduğundan sütun 1'dir.
             guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )
             guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )
       end
       end
       -- we repeat the process for other weapon list, changing the column number
       -- sütun numarasını değiştirerek işlemi diğer silah listesi için tekrarlıyoruz
       row = 0
       row = 0
       for key,weaponName in pairs(machineGun) do
       for key,weaponName in pairs(machineGun) do
             -- we don't need to create new rows as that was done in the previous loop
             -- önceki döngüde yapıldığı gibi yeni satırlar oluşturmamıza gerek yok
             -- we just set the row's text to the weapon name. Column is 2 since the "Machine guns" column was created second.
             -- sadece satırın metnini silah adına ayarladık. "Makineli tüfekler" sütunu ikinci olarak oluşturulduğundan sütun 2'dir.
             guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )
             guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )
             row = row + 1 -- increase the row number
             row = row + 1 -- satır numarasını artır
       end
       end
end
end

Latest revision as of 20:46, 9 August 2021

Bu işlev, yeni bir GUI penceresi oluşturmak içindir. Bu, içinde oluşturulacak diğer GUI öğeleri için bir temel sağlar. Ancak, pencerelerin bir üst öğesi yoktur ve herhangi bir GUI öğesinde oluşturulamaz.

Syntax

element guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )

Gerekli Argümanlar

Örnek Window.
  • x: Bir oyuncunun ekranında GUI penceresinin 2D x konumunun bir kayan nokta. Bu, relative argümandan etkilenir.
  • y: Bir oyuncunun ekranında GUI penceresinin 2B y konumunun bir şamandırası. Bu, relative argümandan etkilenir.
  • width: GUI penceresinin genişliği. Bu, relative argümandan etkilenir.
  • height: GUI penceresinin yüksekliği. Bu, relative argümandan etkilenir.
  • titleBarText: Pencerenin başlık çubuğunda görüntülenecek metin.
  • relative: Bu, boyutların ve konumlandırmanın göreceli olup olmadığıdır. Bu "doğru" ise, tüm x,y,width,height değişkenleri 0 ile 1 arasında olmalıdır ve boyutları/konumları ekran boyutunun bir bölümü olarak temsil eder. "Yanlış" ise, boyut ve koordinatlar müşterinin çözünürlüğüne bağlıdır ve guiGetScreenSize kullanılarak erişilebilir.

Returns

Returns a gui window element if it was created successfully, false otherwise.

Örnek

Örnek 1: Bu örnek bir bilgi penceresi oluşturur ve bir "tabPanel" sekme paneline iki sekme ekler ve ona başka gui öğeleri ekler.

local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Bilgi", true )  -- başlık çubuğunda "Bilgi" olan bir pencere oluşturun.
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow )       -- tüm pencereyi dolduran bir sekme paneli oluşturun
local tabMap = guiCreateTab( "Harita Bilgileri", tabPanel )                -- 'tabPanel' üzerinde "Harita Bilgileri" adlı bir sekme oluşturun
local tabHelp = guiCreateTab( "Yardım", tabPanel )                          -- 'tabPanel' üzerinde "Yardım" adında başka bir sekme oluşturun

-- adds a label (text) to each tab
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "Bu, mevcut harita hakkında bilgidir", true, tabMap)
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "Bu, yardım mesajıdır.", true, tabHelp)

Örnek 2: Bu örnek, bir pencere, kılavuz listesi ve bir düğme ile tamamlanmış bir silah seçim ekranı oluşturur. Kullanıcılar bir av tüfeği veya makineli tüfek seçebilir. Pencere hareketli veya büyük değil.

--Bazı tablolar

shotguns = {
      "chrome",
      "sawn-off",
      "combat"
}

machineGun = {
      "m4",
      "ak-47"
}

function setupWeaponSelection ( theResource )
      -- alttaki getResourceRootElement(getThisResource()), yalnızca bu kaynak başlangıcında gui oluşturacağı anlamına gelir
      -- Açılma ekranımız için "Silahlarınızı seçin" başlıklı bir pencere oluşturun.
      spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Silahlarınızı seçin", true )
      -- kullanıcının seçimlerini onaylamasına izin vermek için bir Tamam düğmesi oluşturun ve bunu onay Seçimi işlevine ekleyin
      spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Tamam", true, spawnScreenMenu )
      -- kullanıcının spawn ekranımızı hareket ettiremediğinden veya yeniden boyutlandıramadığından emin olun.
      guiWindowSetMovable ( spawnScreenMenu, false )
      guiWindowSetSizable ( spawnScreenMenu, false )
      -- pencerenin çoğunu dolduran kılavuz listemizi oluşturun.
      spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )
      guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- seçim modunun sütun başına bir olduğundan emin olun
      -- 2 set silahımız olduğu için av tüfeği için bir sütun ve makineli tüfek için bir sütun oluşturun.
      guiGridListAddColumn ( spawnScreenGridList, "Tüfekler", 0.3 )
      guiGridListAddColumn ( spawnScreenGridList, "Makineli tüfekler", 0.3 )
      -- sonra, ızgara listesine tabanca öğeleri eklemek için tabanca tablomuzda dolaşıyoruz
      for key,weaponName in pairs(shotguns) do
            -- her seferinde ızgara listemize yeni bir satır ekleyin
            local row = guiGridListAddRow ( spawnScreenGridList )
            -- sonra, o satırın metnini silah adına ayarladık. İlk olarak "Av Tüfeği" sütunu oluşturulduğundan sütun 1'dir.
            guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )
      end
      -- sütun numarasını değiştirerek işlemi diğer silah listesi için tekrarlıyoruz
      row = 0
      for key,weaponName in pairs(machineGun) do
            -- önceki döngüde yapıldığı gibi yeni satırlar oluşturmamıza gerek yok
            -- sadece satırın metnini silah adına ayarladık. "Makineli tüfekler" sütunu ikinci olarak oluşturulduğundan sütun 2'dir.
            guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )
            row = row + 1 -- satır numarasını artır
      end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), setupWeaponSelection )

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI