View previous topic :: View next topic |
Author |
Message |
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Mon Mar 04, 2019 11:45 pm Post subject: Encode all instead of 1 (?) |
|
|
The following example: The image code of only 3 images.
But there are 30 images and the code line will multiply.
To shorten the code line, I want a suggestion.
For rare codes and ideas: Thank you in advance.
Code: | form = createForm(true)
form.Position = poDesktopCenter
form.Width = 210
form.Height = 170
b1 = createButton(form)
b1.Left = 120
b1.Top = 30
b1.caption = "Image"
b1.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/YQaPGA.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b1.OnMouseLeave = function()
p1.visible=false
end
end
b2 = createButton(form)
b2.Left = 120
b2.Top = 70
b2.caption = "Image 2"
b2.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/7apmjP.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b2.OnMouseLeave = function()
p1.visible=false
end
end
b3 = createButton(form)
b3.Left = 120
b3.Top = 110
b3.caption = "Image 3"
b3.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/qdaqzB.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b3.OnMouseLeave = function()
p1.visible=false
end
end
p1 = createImage(form)
p1.Left = 15
p1.Top = 40
p1.Height = 87
p1.Width = 87 |
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Mar 05, 2019 1:55 am Post subject: |
|
|
something like this: (don't copy/paste, it may not even compile, just an suggestion)
Code: |
logopath='https://i.hizliresim.com/'
logoimages={'YQaPGA', '7apmjP','qdaqzB'}
logotexts={}
int = getInternet()
local currenttop=30
local i
for i=1,#logoimages do
local bname='b'..i
local b=createButton(form)
_G[bname]=b
b.Left = 120
b.Top = currenttop
currenttop=currenttop+40
b.caption = "Image "..i
b.OnMouseMove = function()
p1.visible=true
local logostr
if logostrs[i] then
logostr=logostrs[i]
else
logostr=int.getURL(logopath..logoimages[i]..'.png')
logostrs[i]=logostr
end
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b1.OnMouseLeave = function()
p1.visible=false
end
end
end
int.destroy ()
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Tue Mar 05, 2019 2:30 am Post subject: |
|
|
Thanks @DB, but it gives a "non-global" error.
I think I'm making mistakes in the review.
Continuous: for "logostr" and "logostrs", wants a definition
and with this code I guess the first step took place.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 05, 2019 4:19 am Post subject: |
|
|
My turn, just a suggestion. Why use 'button' enter and leave for those events. Here a sample uses an 'edit'. Of course, you are free to use any object as you want. Maybe a combobox is the best.
Code: | -- ============================================== Table and Var
myPic_Array = {
{v_url='https://www.goodfreephotos.com/albums/people/asian-guy-drinking-bubble-tea.jpg',idx='1'},
{v_url='https://www.goodfreephotos.com/albums/people/morning-exercises-with-people.jpg',idx='2'},
{v_url='https://www.goodfreephotos.com/albums/people/man-dressed-in-armor-with-sword.jpg',idx='3'}
}
-- ============================================= Functions
function createPictureFromURL(url)
local http = getInternet()
local file = http.getURL(url)
http.destroy()
local picture = createPicture()
local stream = createStringStream(file)
picture.loadFromStream(stream)
return picture
end
function picHide()
if image ~= nil then
image.destroy() -- free memory
stream.destroy()
end
p1.visible=false
end
function picShow()
e_index = tonumber(e1.Text)
if e_index == nil then return nil end
if e_index < 1 or e_index > 3 then
showMessage('Only accept number 0 to 3')
e1.Text = '0'
p1.visible=false
end
index = myPic_Array[e_index]
if index == nil then
return nil
else
if stream ~= nil then stream.destroy() end
image = createPictureFromURL(index.v_url)
p1.visible=true
if picture == nil then
p1.setPicture(image) end
end
end
-- =============================================== GUI
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 210
form.Height = 190
b1 = createLabel(form)
b1.Left = 10
b1.Top = 164
b1.width = 150
b1.Font.Name = 'Cambria'
b1.Font.Size = 10
b1.caption = "Showing Image No.(1~3) : "
--b1.Cursor = -21
p1 = createImage(form)
p1.Left = 10
p1.Top = 10
p1.Height = 140
p1.Width = 190
p1.Stretch = true
p1.visible = false
e1 = createEdit(form)
e1.Left = b1.left + b1.width + 10
e1.Top = 160
e1.width = 25
e1.text = '0'
e1.onChange = picShow
--b1.OnMouseEnter = picShow
--b1.OnMouseLeave = picHide
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Tue Mar 05, 2019 6:51 am Post subject: |
|
|
Thanks @Corroder
But the purpose: to ensure ease.
ie: Lazy user without extra processing.
"Edit" are too lazy to use the idea.
The following code carries samples from the Main panel.
All this will be used with the script.
There are more than 40 Buttons and
18 of them should show pictures.
Code: | form = createForm(true)
form.Position = poDesktopCenter
form.Width = 340
form.Height = 250
form.OnMouseMove = function()
p1.visible=false
l1.caption=""
end
b1 = createButton(form)
b1.Left = 245
b1.Top = 30
b1.caption = "Image"
b1.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/YQaPGA.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b1.OnMouseLeave = function()
p1.visible=false
end
if Lang == '1' then
l1.Caption="Activate: In the kitchen, make Blackberry Jam."
end
if Lang == '2' then
l1.Caption="Aktivieren: In der Küche Blackberry Jam zubereiten."
end
if Lang == '3' then
l1.Caption="Activer: Dans la cuisine, préparez Blackberry Jam."
end
end
b2 = createButton(form)
b2.Left = 245
b2.Top = 70
b2.caption = "Image 2"
b2.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/7apmjP.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b2.OnMouseLeave = function()
p1.visible=false
end
if Lang == '1' then
l1.Caption="Activate: In the kitchen, make pearl tart."
end
if Lang == '2' then
l1.Caption="Aktivieren: In der Küche Perlkuchen machen."
end
if Lang == '3' then
l1.Caption="Activer: Dans la cuisine,\npréparez une tarte aux perles."
end
end
b3 = createButton(form)
b3.Left = 245
b3.Top = 110
b3.caption = "Image 3"
b3.OnMouseMove = function()
p1.visible=true
int = getInternet()
local logostr=int.getURL("https://i.hizliresim.com/qdaqzB.png")
int.destroy ()
local ss=createStringStream(logostr)
p1.Picture.loadFromStream(ss)
ss.destroy()
b3.OnMouseLeave = function()
p1.visible=false
end
if Lang == '1' then
l1.Caption="Activate: In the workshop, search for a certificate."
end
if Lang == '2' then
l1.Caption="Aktivieren: Suchen Sie in der\nWerkstatt nach einem Zertifikat."
end
if Lang == '3' then
l1.Caption="Activer: dans l'atelier, recherchez un certificat."
end
end
p1 = createImage(form)
p1.Left = 80
p1.Top = 40
p1.Height = 87
p1.Width = 87
b4 = createButton(form)
b4.Left = 5
b4.Top = 200
b4.caption = "Language"
b4.font.Style = '[fsBold]'
b4.onClick = function()
b5.visible = true
b6.visible = true
b7.visible = true
end
b5 = createButton(form)
b5.Left = 85
b5.Top = 200
b5.caption = "English"
b5.visible = false
b5.onClick = function()
Lang = '1'
b1.caption = "Picture 1"
b2.caption = "Picture 2"
b3.caption = "Picture 3"
b4.caption = "English"
b5.visible = false
b6.visible = false
b7.visible = false
end
b6 = createButton(form)
b6.Left = 165
b6.Top = 200
b6.caption = "Germany"
b6.visible = false
b6.onClick = function()
Lang = '2'
b1.caption = "Bild 1"
b2.caption = "Bild 2"
b3.caption = "Bild 3"
b4.caption = "Germany"
b5.visible = false
b6.visible = false
b7.visible = false
end
b7 = createButton(form)
b7.Left = 245
b7.Top = 200
b7.caption = "France"
b7.visible = false
b7.onClick = function()
Lang = '3'
b1.caption = "Image 1"
b2.caption = "Image 2"
b3.caption = "Image 3"
b4.caption = "France"
b5.visible = false
b6.visible = false
b7.visible = false
end
l1 = createLabel(form)
l1.Left = 15
l1.Top = 155
l1.autoSize = true
l1.font.Style = '[fsBold]'
|
Please edit the code without "CEEdit"?
Do not use "ImageHide".
The following code will complete this process.
Code: | form.OnMouseMove = function()
p1.visible=false
l1.caption=""
end |
Thank you for your interest.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 05, 2019 8:50 am Post subject: |
|
|
try this, I did just for image show. Remains is yours.
Code: | -- ============================================== Table and Var
myPic_Array = {
{v_url='https://www.goodfreephotos.com/albums/people/asian-guy-drinking-bubble-tea.jpg',idx='1'},
{v_url='https://www.goodfreephotos.com/albums/people/morning-exercises-with-people.jpg',idx='2'},
{v_url='https://www.goodfreephotos.com/albums/people/man-dressed-in-armor-with-sword.jpg',idx='3'}
}
-- ============================================= Functions
function createPictureFromURL(url)
local http = getInternet()
local file = http.getURL(url)
http.destroy()
local picture = createPicture()
local stream = createStringStream(file)
picture.loadFromStream(stream)
stream.destroy()
return picture
end
function picHide()
if image ~= nil then
image.destroy() -- free memory
end
p1.visible=false
end
function picShow(sender)
b_name = sender.Name
b_index = tonumber(string.sub(b_name,-1))
index = myPic_Array[b_index]
if index == nil then
return nil
else
image = createPictureFromURL(index.v_url)
p1.visible=true
if picture == nil then
p1.setPicture(image) end
end
end
-- =============================================== GUI
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 210
form.Height = 200
b1 = createButton(form)
b1.Left = 5
b1.Top = 164
b1.width = 60
b1.Font.Name = 'Cambria'
b1.Font.Size = 10
b1.caption = "Pic.1"
b1.Cursor = -21
b1.Name = 'b1'
b2 = createButton(form)
b2.Left = b1.left + b1.width + 10
b2.Top = 164
b2.width = 60
b2.Font.Name = 'Cambria'
b2.Font.Size = 10
b2.caption = "Pic.2"
b2.Cursor = -21
b2.Name = 'b2'
b3 = createButton(form)
b3.Left = b2.left + b2.width + 10
b3.Top = 164
b3.width = 60
b3.Font.Name = 'Cambria'
b3.Font.Size = 10
b3.caption = "Pic.3"
b3.Cursor = -21
b3.Name = 'b3'
p1 = createImage(form)
p1.Left = 10
p1.Top = 10
p1.Height = 140
p1.Width = 190
p1.Stretch = true
b1.OnMouseEnter = picShow
b1.OnMouseLeave = picHide
b2.OnMouseEnter = picShow
b2.OnMouseLeave = picHide
b3.OnMouseEnter = picShow
b3.OnMouseLeave = picHide |
Note, button names (sender) always end with number, as you see it was like 'b1','b2','b3'...
1,2,3 use for index number lookup on 'myPic_Array' table as above.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Tue Mar 05, 2019 10:52 am Post subject: |
|
|
Corroder wrote: | try this, I did just for image show. Remains is yours.
Code: | -- ============================================== Table and Var
myPic_Array = {
{v_url='https://www.goodfreephotos.com/albums/people/asian-guy-drinking-bubble-tea.jpg',idx='1'},
{v_url='https://www.goodfreephotos.com/albums/people/morning-exercises-with-people.jpg',idx='2'},
{v_url='https://www.goodfreephotos.com/albums/people/man-dressed-in-armor-with-sword.jpg',idx='3'}
}
-- ============================================= Functions
function createPictureFromURL(url)
local http = getInternet()
local file = http.getURL(url)
http.destroy()
local picture = createPicture()
local stream = createStringStream(file)
picture.loadFromStream(stream)
stream.destroy()
return picture
end
function picHide()
if image ~= nil then
image.destroy() -- free memory
end
p1.visible=false
end
function picShow(sender)
b_name = sender.Name
b_index = tonumber(string.sub(b_name,-1))
index = myPic_Array[b_index]
if index == nil then
return nil
else
image = createPictureFromURL(index.v_url)
p1.visible=true
if picture == nil then
p1.setPicture(image) end
end
end
-- =============================================== GUI
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 210
form.Height = 200
b1 = createButton(form)
b1.Left = 5
b1.Top = 164
b1.width = 60
b1.Font.Name = 'Cambria'
b1.Font.Size = 10
b1.caption = "Pic.1"
b1.Cursor = -21
b1.Name = 'b1'
b2 = createButton(form)
b2.Left = b1.left + b1.width + 10
b2.Top = 164
b2.width = 60
b2.Font.Name = 'Cambria'
b2.Font.Size = 10
b2.caption = "Pic.2"
b2.Cursor = -21
b2.Name = 'b2'
b3 = createButton(form)
b3.Left = b2.left + b2.width + 10
b3.Top = 164
b3.width = 60
b3.Font.Name = 'Cambria'
b3.Font.Size = 10
b3.caption = "Pic.3"
b3.Cursor = -21
b3.Name = 'b3'
p1 = createImage(form)
p1.Left = 10
p1.Top = 10
p1.Height = 140
p1.Width = 190
p1.Stretch = true
b1.OnMouseEnter = picShow
b1.OnMouseLeave = picHide
b2.OnMouseEnter = picShow
b2.OnMouseLeave = picHide
b3.OnMouseEnter = picShow
b3.OnMouseLeave = picHide |
Note, button names (sender) always end with number, as you see it was like 'b1','b2','b3'...
1,2,3 use for index number lookup on 'myPic_Array' table as above. |
That's a good final.
Thanks #Corroder.
You're done without transferring the seizure. Thanks again. +1
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Mar 05, 2019 6:20 pm Post subject: |
|
|
@Aylin : I forgot to tell you, because your pictures more than 10 images, then change this line :
Code: | b_index = tonumber(string.sub(b_name,-1))
-- change to
b_index = tonumber(string.sub(b_name,-2)) |
and for button name you need change to : 'b01', 'b02'..'b11'...etc
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Tue Mar 12, 2019 5:14 am Post subject: |
|
|
Corroder wrote: | @Aylin : I forgot to tell you, because your pictures more than 10 images, then change this line :
Code: | b_index = tonumber(string.sub(b_name,-1))
-- change to
b_index = tonumber(string.sub(b_name,-2)) |
and for button name you need change to : 'b01', 'b02'..'b11'...etc |
Big Thanks @Corroder
With the code you've finalized, the project is complete.
Below is a new project.
You must take a look.
I'll send you the .CT file for your review.
Video for now and Cetrainer.
.Cetrainer: https://www.dosyaupload.com/ew2q
Video: https://youtu.be/XYT006bUIig
ImageURL: https://i.hizliresim.com/16olEb.png
Enjoy it!
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
|
Back to top |
|
|
|