Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Chockosta

Pages: 1 ... 11 12 [13] 14 15 ... 31
181
Miscellaneous / Re: Post your desktop
« on: January 08, 2012, 04:30:35 pm »
Agreed.... @chockosta What version of Ubuntu is that? Looks like 9.10 (my favorite one) but if its 11.10, how did you get it to look like that?
It's 10.04 LTS...

182
Miscellaneous / Re: Post your desktop
« on: January 08, 2012, 04:16:54 pm »
Here is mine (with Ubuntu)

183
TI-Nspire / Re: [Lua] Image Editor
« on: January 06, 2012, 02:07:03 pm »
Some progress...
Now buttons work, and there is a draft of custom window layouts.

If you're interested, here is the code of the new sample :
Code: [Select]
--[[

window : {wtype,name,buttons,layout,size}
   --> wtype : "dialogBox","custom"
   --> size : {sizeX,sizeY} (only for custom)

buttons : {{"name",function1},{"name",function2},...}

layout : {{"type",...}}
   --> type : "label","textBox","colorSlider","list"

label : {text,x,y}

textBox : {text,x,y,sizeX,cursor}

colorSlider : {color,value,x,y}
   --> color : "red","green","blue"

list : {elements,scroll,x,y,sizeX,sizeY}

]]


--GUI GESTION
gui={}
gui.windows={}
gui.dialogBox={}
gui.custom={}
gui.resized=false

function gui.errorMessage(errorText)
 gui.addWindow("dialogBox","Error",{{"OK",function() gui.closeWindow() refresh() end}},errorText)
end

function gui.addWindow(windowType,windowName,windowButtons,windowLayout,windowSize)
 table.insert(gui.windows,{wtype=windowType,name=windowName,buttons=windowButtons,layout=windowLayout,size=windowSize})
 gui.focus=-1
end

function gui.closeWindow()
 table.remove(gui.windows)
 gui.focus=-1
end

function gui.nbWindows()
 return #gui.windows
end

function gui.current()
 return gui.windows[#gui.windows]
end

function gui.paint(gc)
 for i,e in pairs(gui.windows) do
  gui[e.wtype].paint(gc,e,i)
 end
 gui.resized=false
end

function gui.resize()
 gui.resized=true
end




--GUI DRAWING

function gui.dialogBox.paint(gc,dialogBox,windowID)
 local sizeX,sizeY
 if not dialogBox.size then
  gc:setFont("sansserif","r",10)
  sizeX=improvedStr.width(gc,dialogBox.layout)+24
  sizeY=improvedStr.height(gc,dialogBox.layout)+17
  gui.windows[windowID].size={sizeX,sizeY}
 else
  sizeX,sizeY=unpack(dialogBox.size)
 end
 gui.paintWindowBG(gc,dialogBox.name,sizeX,sizeY)
 gui.paintTextArea(gc,dialogBox.layout,sizeX,sizeY)
 gui.paintButtons(gc,dialogBox.buttons,sizeX,sizeY,windowID)
 if windowID==#gui.windows then
  gui.paintFocus(gc,gui.focus,dialogBox.buttons,dialogBox.layout,sizeX,sizeY)
 end
end

function gui.custom.paint(gc,window,windowID)
 gui.paintWindowBG(gc,window.name,window.size[1],window.size[2])
 gui.paintLayout(gc,window.layout,window.size[1],window.size[2],windowID)
 gui.paintButtons(gc,window.buttons,window.size[1],window.size[2],windowID)
 if windowID==#gui.windows then
  gui.paintFocus(gc,gui.focus,window.buttons,window.layout,window.size[1],window.size[2])
 end
end





function gui.paintLayout(gc,layout,sizeX,sizeY,windowID)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 for i,e in pairs(layout) do
  if e[1]=="textBox" then
   gui.paintTextBox(gc,e,x,y)
  elseif e[1]=="label" then
   gc:setFont("sansserif","r",10)
   gc:setColorRGB(0,0,0)
   gc:drawString(e.text,x+e.x,y+e.y,"top")
  elseif e[1]=="colorSlider" then
   gui.paintColorSlider(gc,e,x,y)
  end
 end
end

function gui.paintTextBox(gc,textBox,x,y)
 gc:setColorRGB(255,255,255)
 gc:fillRect(x+textBox.x,y+textBox.y,textBox.sizeX,22)
 gc:setColorRGB(0,0,0)
 gc:drawRect(x+textBox.x,y+textBox.y,textBox.sizeX,22)
 gc:drawString(string.sub(textBox.text,1,textBox.cursor-1).."|"..string.sub(textBox.text,textBox.cursor),x+textBox.x+3,y+textBox.y,"top")
end

function gui.paintColorSlider(gc,slider,x,y)
 gc:setColorRGB(0,0,0)
 gc:fillRect(x+slider.x,y+slider.y,68,14)
 for i=0,63 do
  gc:setColorRGB(slider.color=="red" and i*4 or color[1],slider.color=="green" and i*4 or color[2],slider.color=="blue" and i*4 or color[3])
  gc:fillRect(x+slider.x+i+2,y+2+slider.y,1,10)
 end
 gc:setColorRGB(0,0,0)
 gc:fillRect(x+slider.x+slider.value/4+1,y+slider.y,1,12)
 gc:fillRect(x+slider.x+slider.value/4+3,y+slider.y,1,12)
end

function gui.paintButtons(gc,buttons,sizeX,sizeY,windowID)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if (not buttons[1].size) or gui.resized then
  local totalSize,size,pos=-7,{},{}
  for i,e in pairs(buttons) do
   size[i]=gc:getStringWidth(e[1])+10
   totalSize=totalSize+size[i]+7
  end
  pos[1]=(width()-totalSize)/2
  for i=2,#buttons do
   pos[i]=pos[i-1]+size[i-1]+7
  end
  for i,e in pairs(buttons) do
   gui.windows[windowID].buttons[i].size=size[i]
   gui.windows[windowID].buttons[i].pos=pos[i]
  end
  buttons=gui.windows[windowID].buttons
 end
 for i,e in pairs(buttons) do
  gc:setColorRGB(136,136,136)
  gc:fillRect(e.pos,y+sizeY+9,e.size,23)
  gc:fillRect(e.pos+1,y+sizeY+8,e.size-2,25)
  gc:fillRect(e.pos+2,y+sizeY+7,e.size-4,27)
  gc:setColorRGB(255,255,255)
  gc:fillRect(e.pos+2,y+sizeY+9,e.size-4,23)
  gc:setColorRGB(0,0,0)
  gc:drawString(e[1],e.pos+5,y+sizeY+20,"middle")
 end
end

function gui.paintTextArea(gc,text,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if isCX() then
  gc:setColorRGB(128,128,128)
 else
  gc:setColorRGB(255,255,255)
 end
 gc:drawRect(x+6,y+6,sizeX-13,sizeY-13)
 gc:setColorRGB(0,0,0)
 improvedStr.draw(gc,text,x+12,y+9)
end

function gui.paintWindowBG(gc,name,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if isCX() then
  gc:setColorRGB(100,100,100)
 else
  gc:setColorRGB(200,200,200)
 end
 gc:fillRect(x-1,y-23,sizeX+4,sizeY+65)
 gc:fillRect(x,y-22,sizeX+4,sizeY+65)
 gc:fillRect(x+1,y-21,sizeX+4,sizeY+65)
 if isCX() then
  gc:setColorRGB(128,128,128)
 else
  gc:setColorRGB(0,0,0)
 end
 gc:fillRect(x-2,y-24,sizeX+4,sizeY+65)
 if isCX() then
  for i=1,22 do
   gc:setColorRGB(32+i*3,32+i*3,32+i*3)
   gc:fillRect(x,y+i-23,sizeX,1)
  end
 else
  gc:setColorRGB(0,0,0)
  gc:fillRect(x,y-22,sizeX,22)
 end
 gc:setColorRGB(255,255,255)
 gc:setFont("sansserif","r",10)
 gc:drawString(name,x+2,y-9,"baseline")
 gc:setColorRGB(224,224,224)
 gc:fillRect(x,y,sizeX,sizeY+39)
 gc:setColorRGB(128,128,128)
 gc:fillRect(x+6,y+sizeY,sizeX-12,2)
end

function gui.paintFocus(gc,focus,buttons,layout,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if focus>0 then
  if type(layout)=="table" then

  end
 elseif focus<0 then
  local button=buttons[-focus]
  if isCX() then
   gc:setColorRGB(50,150,190)
  else
   gc:setColorRGB(0,0,0)
  end
  gc:drawRect(button.pos-3,y+sizeY+4,button.size+5,32)
  gc:drawRect(button.pos-2,y+sizeY+5,button.size+3,30)
 end
end




--GUI EVENTS
function gui.mouseDown(xPos,yPos)
 if gui.nbWindows()>=1 then
  local window=gui.current()
  if window.size then
   local sizeX,sizeY=unpack(window.size)
   local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
   if xPos>x and xPos<x+sizeX and yPos>y then
    if yPos<y+sizeY then
     gui.setFocus(xPos,yPos,window)
    elseif yPos<y+sizeY+39 then
     gui.buttonDown(xPos,yPos,window.buttons)
    end
   end
  end
 end
end

function gui.buttonDown(x,y,buttons)
 for i,e in pairs(buttons) do
  if x>e.pos and x<e.pos+e.size then
   gui.focus=-i
   e[2]()
  end
 end
end

function gui.setFocus(x,y,window)
 
end


--MULTIPLE LINE STRING GESTION
improvedStr={}

function improvedStr.draw(gc,str,x,y)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 for i,e in pairs(table1) do
  gc:drawString(e,x,y+(i-1)*gc:getStringHeight("a"),"top")
 end
end

function improvedStr.width(gc,str)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 local table2={}
 for i,e in pairs(table1) do
  table2[i]=gc:getStringWidth(e)
 end
 table.sort(table2)
 return table2[#table2]
end

function improvedStr.height(gc,str)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 return gc:getStringHeight("a")*#table1
end

function improvedStr.cut(str)
 local table1,finished={},false
 local posStart,posEnd,last=1,0,1
 while not finished do
  posStart,posEnd=string.find(str,"\n",posEnd+1)
  if posStart then
   table.insert(table1,string.sub(str,last,posStart-1))
   last=posEnd+1
  else
   table.insert(table1,string.sub(str,last))
   finished=true
  end
 end
 return unpack(table1)
end

184
TI-Nspire / Re: [Lua] Image Editor
« on: January 01, 2012, 04:35:44 am »
@Adriweb :
I didn't take any routine from EEPro. If I did, I would have mentioned it. By the way, I didn't know that the source code of EEPro was visible... Where could I see it ?
You sure can use my code, but for now there is almost nothing. (no event gestion, no custom layout...)
And it might not be easy since I don't use OOP.

@DJ_O :
Thanks !

@jimbauwens :
I would be honored to share ideas with you, but my little GUI engine is nothing compared to EEPro API. I will just add text boxes, and it will be enough for me...

If you want the code of this sample, here it is :
Code: [Select]
--GUI GESTION
gui={}
gui.windows={}
gui.dialogBox={}

function gui.errorMessage(errorText)
 gui.addWindow("Error","dialogBox",errorText,{{"OK"}})
end

function gui.addWindow(windowName,windowType,text,buttons)
 table.insert(gui.windows,{windowName,windowType,text,buttons})
end

function gui.closeWindow()
 table.remove(gui.windows)
end

function gui.nbWindows()
 return #gui.windows
end

function gui.current()
 return gui.windows[#gui.windows]
end

function gui.paint(gc)
 for i,e in pairs(gui.windows) do
  gui[e[2]].paint(gc,e)
 end
end

function gui.dialogBox.paint(gc,dialogBox)
 gc:setFont("sansserif","r",10)
 local sizeX=improvedStr.width(gc,dialogBox[3])+24
 local sizeY=improvedStr.height(gc,dialogBox[3])+17
 gui.paintWindowBG(gc,dialogBox[1],sizeX,sizeY)
 gui.paintTextArea(gc,dialogBox[3],sizeX,sizeY)
 gui.paintButtons(gc,dialogBox[4],sizeX,sizeY)
end

function gui.paintButtons(gc,buttons,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 local size,totalSize,pos={},-7,{}
 for i,e in pairs(buttons) do
  size[i]=gc:getStringWidth(e[1])+10
  totalSize=totalSize+size[i]+7
 end
 pos[1]=(width()-totalSize)/2
 for i=2,#buttons do
  pos[i]=pos[i-1]+size[i-1]+7
 end
 for i,e in pairs(buttons) do
  gc:setColorRGB(136,136,136)
  gc:fillRect(pos[i],y+sizeY+9,size[i],23)
  gc:fillRect(pos[i]+1,y+sizeY+8,size[i]-2,25)
  gc:fillRect(pos[i]+2,y+sizeY+7,size[i]-4,27)
  gc:setColorRGB(255,255,255)
  gc:fillRect(pos[i]+2,y+sizeY+9,size[i]-4,23)
  gc:setColorRGB(0,0,0)
  gc:drawString(e[1],pos[i]+5,y+sizeY+20,"middle")
 end
end

function gui.paintTextArea(gc,text,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if isCX() then
  gc:setColorRGB(128,128,128)
 else
  gc:setColorRGB(255,255,255)
 end
 gc:drawRect(x+6,y+6,sizeX-13,sizeY-13)
 gc:setColorRGB(0,0,0)
 improvedStr.draw(gc,text,x+12,y+9)
end

function gui.paintWindowBG(gc,name,sizeX,sizeY)
 local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2
 if isCX() then
  gc:setColorRGB(100,100,100)
 else
  gc:setColorRGB(200,200,200)
 end
 gc:fillRect(x-1,y-23,sizeX+4,sizeY+65)
 gc:fillRect(x,y-22,sizeX+4,sizeY+65)
 gc:fillRect(x+1,y-21,sizeX+4,sizeY+65)
 if isCX() then
  gc:setColorRGB(128,128,128)
 else
  gc:setColorRGB(0,0,0)
 end
 gc:fillRect(x-2,y-24,sizeX+4,sizeY+65)
 if isCX() then
  for i=1,22 do
   gc:setColorRGB(32+i*3,32+i*3,32+i*3)
   gc:fillRect(x,y+i-23,sizeX,1)
  end
 else
  gc:setColorRGB(0,0,0)
  gc:fillRect(x,y-22,sizeX,22)
 end
 gc:setColorRGB(255,255,255)
 gc:setFont("sansserif","r",10)
 gc:drawString(name,x+2,y-9,"baseline")
 gc:setColorRGB(224,224,224)
 gc:fillRect(x,y,sizeX,sizeY+39)
 gc:setColorRGB(128,128,128)
 gc:fillRect(x+6,y+sizeY,sizeX-12,2)
end




--MULTIPLE LINE STRING GESTION
improvedStr={}

function improvedStr.draw(gc,str,x,y)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 for i,e in pairs(table1) do
  gc:drawString(e,x,y+(i-1)*gc:getStringHeight("a"),"top")
 end
end

function improvedStr.width(gc,str)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 local table2={}
 for i,e in pairs(table1) do
  table2[i]=gc:getStringWidth(e)
 end
 table.sort(table2)
 return table2[#table2]
end

function improvedStr.height(gc,str)
 str=tostring(str)
 local table1={improvedStr.cut(str)}
 return gc:getStringHeight("a")*#table1
end

function improvedStr.cut(str)
 local table1,finished={},false
 local posStart,posEnd,last=1,0,1
 while not finished do
  posStart,posEnd=string.find(str,"\n",posEnd+1)
  if posStart then
   table.insert(table1,string.sub(str,last,posStart-1))
   last=posEnd+1
  else
   table.insert(table1,string.sub(str,last))
   finished=true
  end
 end
 return unpack(table1)
end

-- END OF GUI
 
function width() return platform.window:width() end
function height() return platform.window:height() end
function isCX() return platform.isColorDisplay() end
 
gui.addWindow("Title","dialogBox","This text shows multi-line text functions :\nLorem ipsum dolor sit amet",{{"Button 1"},{"Button 2"},{"Another button"}})

function on.paint(gc)
 gui.paint(gc)
end

185
TI-Nspire / Re: [Lua] Image Editor
« on: December 31, 2011, 11:13:53 am »
Some work on the GUI...
It is now possible to open a native-like window with 1 line :
Code: [Select]
gui.addWindow("Title","dialogBox","This text shows multi-line text functions :\nLorem ipsum dolor sit amet",{{"Button 1"},{"Button 2"},{"Another button"}})
See attachment for result.

186
TI-Nspire / Re: [Lua] Image Editor
« on: December 28, 2011, 02:19:32 pm »
I am currently rewriting this project...
It should not take too much time, so expect some news soon...

187
TI-Nspire / Re: [Lua] Gravity guy
« on: December 23, 2011, 09:40:43 am »
Adriweb :
I'll upload it when at least 20 levels will be done.

Levak :
I know, the grey square is just here for developpement purposes (collision box)

By the way, I'm now at my grandparent's for christmas, and I didn't bring any of my Nspires. So no more updates during this week...

188
TI-Nspire / Re: [Lua] Gravity guy
« on: December 22, 2011, 09:05:20 am »
I finished the collision engine, and everything else.
Now I just have to create 50 levels :(
(And I haven't created the random mode)

If you want to try it, there is the current file attached. It contains 8 test levels (which are very short and not funny).
Oh, and I still haven't choosen a better sprite.

189
TI-Nspire / Re: SpeedX 3D
« on: December 22, 2011, 08:57:05 am »
This is amazing !
Really, congrats.

And, you can try the spiral, but I think it will be too slow...

190
Other Calculators / Re: Periodic table
« on: December 20, 2011, 05:26:01 pm »
Yeah, you're right. This might not be a great idea.
Anyway, it's already much better that TI's version.

191
Other Calculators / Re: Periodic table
« on: December 20, 2011, 05:10:56 pm »
how do you mean? of the element? the atom or a real view?
I was thinking about something like that http://theodoregray.com/PeriodicTable/Posters/Poster3.2000.JPG

192
Other Calculators / Re: Periodic table
« on: December 20, 2011, 12:39:51 pm »
Oh, by the way, I have a suggestion : it would be even better if the program displayed a little picture of the selected element.

193
Other Calculators / Re: Periodic table
« on: December 20, 2011, 11:45:13 am »
Really nice !
And I'm glad that Tiny3D is useful :)

194
TI-Nspire / Re: [Lua] Gravity guy
« on: December 15, 2011, 04:37:42 pm »
By linear gravity, I mean that the character doesn't accelerate while falling.
It is more arcade-like, but less realistic.

I'll do an animated screenshot when my collision engine will be finished...

195
TI-Nspire / [Lua] Gravity guy
« on: December 15, 2011, 03:47:57 pm »
FINAL UPDATE : 14/04/2012
Spoiler For Spoiler:
Download




Moving screenshot (thanks to Jonius7). The actual game is slower...


Hi there !

Sorry if I may seem inactive, but I am in a 'non-motivation' period.
But I'm not dead (even if I only program 2 hours a week).
So my latest project is a Gravity Guy clone. It is quite fast (and really blurry on grayscale nspires)

Some screenies are attached to my post.

Note that I will change the player sprite.
And, by the way, I used linear gravity (like the original game). Should I use more realistic calculations ?

Pages: 1 ... 11 12 [13] 14 15 ... 31