If I run and write #TEMP#, then its would open Explodere with Temp folder directory. Howover I trying to do that with #DROPBOX#, because I think its would been cool if I could get DROPBOX to work on a least iOS, Android, Windows and Mac. Howover Android require Java and then its impossible to due as long you cant call java from inline.
on Windows its would been so simple as #DROPBOX# that get the user folder, but its not working with either SETCURRENTDIR() as well DOESDIREXIST(). If its worked with SETCURRENTDIR$(), then there would been compare with a simple string test.
this is not a glbasic bug, but would been nice if that was possible, eventuelly using inline?
PS. Im trying to use DROPBOX for the game could SYNC with thier devices (regaardless on system, except by now WebOS and Android). If I got success, then I put its in code snippet. But there is no final date on that yet, nor even its would relaese with Greedy Mouse v1.0.
[attachment deleted by admin]
#TEMP# is probably just GLBasic accessing the user variable TEMP in the Windows Environment Variable.
If you type %temp% in the Start\Run text box it'll open your temp folder.
As dropbox doesn't add the current directory it's using as a user variable
you'd have to get it from
C:\Users\THECURRENTUSER\AppData\Roaming\Dropbox\host.db (The location would be different on XP)
which is in BASE64 format, and then make it as a user variable
but if the user ever changes the dropbox directory you're fecked
So you'd have to just get it from the host.db and use it but you'd probably need
to check it on each run to make sure it hasn't changed
https://www.dropbox.com/votebox/1059/add-dropbox-as-an-envirionment-variable-for-windows
PLATFORMINFO$ would be the more appropriate place for getting locations of things. There is already "TEMP" there...
But not for example dropbox user variable. Here its would been nice if SETCURRENTDIR could check for that. You can allways use string variable to set the path back again eventuelly.
Temp was also a example to (even its can been checked, but I do not use that). Property it's a inline thing.
When you enter "set" in a cmd.exe, is there a dropbox variable?
That could be read with getenv$
Unfortunately DropBox doesn't create a system variable...
Its me that is stupid =D.
Of course #DROPBOX# just launch Dropbox.exe and all its does is of course launch explorer with its path. Nothing special. Here I just got confuction its was setup a variable. But howover sadly there is no system variable, which I find is dumb.
Howover I do could find a way to find and open host.db and I just need to base64 decode it (no expert, but the download link I found is down) and find its default url (if its exists of course).
Howover list of system variable using set did help where I could locate AppData/Roaming folder.
PS. I did created my own base64 decoder. its was pretty much very easy, dispite missing num2bin$ as well bin2dec (but there is allready functions doing it). I Post it later when I have got it to work in the code snippes. Its might take a week or two or sometime. But I will open DROPBOX integration when done (more than just Windows).
Quote from: spacefractal on 2012-Aug-16
Howover I do could find a way to find and open host.db and I just need to base64 decode it (no expert, but the download link I found is down) and find its default url (if its exists of course).
There is no regkey for the dropbox folder :(. But, you are right, if you decode with Base64 the second line in %AppData%\Dropbox\host.db you get the dropbox folder path. This is only for Windows, of course.
@Spacefractal: maybe you could ask moru if he can reupload his great base64 code, so you dont need to do the work again. Too bad his website is down, lets hope he has an backup. I just have an copy of his encode function, but not of the decode one in my archiv.
Ofcourse I have backups. I'm just tired of fighting with this hosting company. I'll attach the file including some example of sharing a file over a webserver with PHP and MySQL (I think, old files :-)
I don't have time to check that it actually works in the new GLBasic versions, please let me know how it goes for you!
[attachment deleted by admin]
I allready created base64 decoder and its was plain simple to do.
i would and try use dropbox for gamesave sync for greedy mouse, so you could play the game and resume on any device.
The hard part me guess is andriod version, due no call from c++ to java yet.
When I a day got it to work with comply of platform I add to code snippet.
But I do can't take account others would do the same, so it's better to find and decode host.db
This gives a good idea of how to find it. Unfortunately SQLite needs to be used...
https://forums.dropbox.com/topic.php?id=10551
its easier to extract it from host.db, much easier.
Since I think DROPBOX would been excellent to been include in GLBASIC, this thread should rename as a Dropbox integration project (Im not sure I should rename, so I leave it as its are). Here is what I came with to detect the folder of it, and eventuelly create the subfolder:
GLOBAL DROPBOXDIR$=""
GLOBAL DROPBOXLOCALFOLDER$="GreedyMouse_SaveData"
GLOBAL DROPBOXAPPKEY$=""
GLOBAL DROPBOXSECRETKEY$=""
FUNCTION Dropbox_Init:
IF PLATFORMINFO$("")="WIN32"
LOCAL file$=GETENV$("APPDATA")+"/dropbox/host.db"
file$=REPLACE$(file$, CHR$(134), "/")
IF DOESFILEEXIST(file$)
LOCAL ok=OPENFILE(1, file$, 1)
IF ok
LOCAL line$
WHILE ENDOFFILE(1)=0
READLINE 1, line$
line$=BASE64Decode$(line$)
IF LEN(line$)>10
IF DOESDIREXIST(line$)
DROPBOXDIR$=line$
DROPBOXDIR$=REPLACE$(DROPBOXDIR$, "\\", "/")
BREAK
ENDIF
ENDIF
WEND
ENDIF
ENDIF
file$=REPLACE$(file$, "\\", "/")
ENDIF
IF DROPBOXLOCALFOLDER$<>""
IF DOESDIREXIST(DROPBOXDIR$+"/"+DROPBOXLOCALFOLDER$)=0
CREATEDIR(DROPBOXDIR$+"/"+DROPBOXLOCALFOLDER$)
ENDIF
ENDIF
DEBUG "Dropbox Folder: "+DROPBOXDIR$
ENDFUNCTION
FUNCTION Dropbox_Upload: LocalFile$, CloudFile$
ENDFUNCTION
FUNCTION Dropbox_Download: CloudFile$, LocalFile$
ENDFUNCTION
FUNCTION BASE64Decode$: String$
LOCAL keyStr$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
LOCAL result$=""
LOCAL a$, b$, c$, d$
FOR i=0 TO LEN(String$)
a$=MID$(String$, i, 1)
IF INSTR(keyStr$, a$, 0)>-1 THEN result$=result$+a$
NEXT
String$=result$
LOCAL strresult$=""
FOR i=0 TO LEN(String$) STEP 4
a$=MID$(String$, i, 1);
IF a$<>"="
LOCAL a=INSTR(keyStr$, a$, 0); a$=Bin$(a, 1); a$=RIGHT$(a$, 6)
b$=MID$(String$, i+1, 1);
IF b$<>"="
LOCAL b=INSTR(keyStr$, b$, 0); b$=Bin$(b, 1); b$=RIGHT$(b$, 6)
c$=MID$(String$, i+2, 1);
IF c$<>"="
LOCAL c=INSTR(keyStr$, c$, 0); c$=Bin$(c, 1); c$=RIGHT$(c$, 6)
d$=MID$(String$, i+3, 1);
IF d$<>"="
LOCAL d=INSTR(keyStr$, d$, 0); d$=Bin$(d, 1); d$=RIGHT$(d$, 6)
ENDIF
ENDIF
ENDIF
ENDIF
result$=a$+b$+c$+d$
LOCAL ch1$=MID$(result$, 0, 8); ch1$=Bin2Dec(ch1$); IF INTEGER(ch1$)<255 AND INTEGER(ch1$)>32 THEN strresult$=strresult$+CHR$(INTEGER(ch1$))
LOCAL ch2$=MID$(result$, 8, 8); ch2$=Bin2Dec(ch2$); IF INTEGER(ch2$)<255 AND INTEGER(ch2$)>32 THEN strresult$=strresult$+CHR$(INTEGER(ch2$))
LOCAL ch3$=MID$(result$, 16, 8); ch3$=Bin2Dec(ch3$); IF INTEGER(ch3$)<255 AND INTEGER(ch3$)>32 THEN strresult$=strresult$+CHR$(INTEGER(ch3$))
a$=""; b$=""; c$=""; d$=""
NEXT
RETURN strresult$
ENDFUNCTION
FUNCTION Bin$: p_num, p_bytes = 4
LOCAL l_length = p_bytes * 8, l_counter, l_result$
FOR l_counter = l_length - 1 TO 0 STEP -1
IF bAND(p_num,POW(2, l_counter))
l_result$ = l_result$ + "1"
ELSE
l_result$ = l_result$ + "0"
ENDIF
NEXT
RETURN l_result$
ENDFUNCTION
FUNCTION Bin2Dec: binnum$
LOCAL l_result, l_counter, l_length
l_length = LEN(binnum$) - 1
FOR l_counter = l_length TO 0 STEP -1
IF MID$(binnum$, l_counter, 1) = 1
INC l_result, POW(2, l_length - l_counter)
ENDIF
NEXT
RETURN l_result
ENDFUNCTION
The goal is of course is get it to work on so many platforms as possible. I think savegame integration across platforms would been very cool to have (later its could go for iCloud for mac as well).
PS. Thread is renamed as i see, that pretty nice. I hope to see and do more code. Today I did some work on the waterpart in the game (also nothing dropbox today). The part works now.
That will work until something changes :)
on MacOSX (And property Linux), host.db is also exists, and its seen its allways should been in ~/.dropbox, so the full path+file should been ~/.dropbox/host.db.
But if I trying to check if the file exists with DOESFILEEXIST, its allways return 0 for some reason? I guess its something different with ~ char my guess? The file also exists on my mac and I'm not using Mountian Lion. Just Lion.
Sounds like a lot of work for the user to get a game working. Why not put up your own server that you can talk to with HTTP requests? My base64 library contains some code for that and there is some examples in the example folder of GLBasic distribution too. You can upload and download files from any webserver, not just dropbox. And this works on all platforms without the user having to install and set up dropbox first.
Because if the game got succes and plans to release to many platforms, then I would not been afford the traffic there would been incomming. So I prefer using a Cloud service like Dropbox (but could been different, example iCloud, but its only for Apple machines) or other Sync services.
The dropbox path is extracted on Windows, but missing on Mac, because I not very sure why ~/.dropbox/host.db cannot been detected correctly. The files elsewise exsits on my Mac.
The major problems is really on mobile platforms, not on deskops (where I awsume Dropbox is installed). Howover on WebOS and other unsupported OS, here server mightbeen required, but there is a Dropbox for PHP as well, which is possible to use.
The very best is of course possible to use the Dropbox's REST API directly in C++ and adapt it using inline. Howover its use HTTPS as well both GET and POST and those are unsupported by GLBASIC.
I agree with moru, i dont see a reason why you try to support the most restricted service thats out there. Wouldnt it be easier to just use one of the thousands free webspace providers out there and upload your data via php or ftp?
And btw would your dropbox solution work if the user dont have dropbox installed? There many ppl that dont like/use dropbox, i bet im not the only one. So dont chain your game to an restricted commercial provider, better look for a free service. just my 2 cents, no offence.
Dropbox is of course option, not required for the user. Dropbox support in game would simple been auto disabled, If not installed on desktop or not autorized by user for mobile. So it's just a extra service for the game.
Dropbox is still best cloud service (as I known) and I don't want to hold server my self and doing all the security work (a account system is required anyway).
I trying to integrate for savegames use, not hiscore. With hiscore, it's different story.
Ps. iCloud would been nice too, also I love Dropbox.
I'd use my own server traffic isnt gonna be a problem really. More traffic=More people bought your product
Quote from: spacefractal on 2012-Aug-19
Because if the game got succes and plans to release to many platforms, then I would not been afford the traffic there would been incomming.
Quote from: spicypixel on 2012-Sep-10
I'd use my own server traffic isnt gonna be a problem really. More traffic=More people bought your product
I agree with spicypixel. Remember that the amount of traffic you send back and forth from a phone/tablet device doesn't amount to much.
Besides, I'd think it would be better to be in control of as much as possible, and not be dependent on too many third-parties.
I need account based, but have not Got more far with integration, because i want V1.0 of greedy mouse out first.
I perfer dropbox due platforms supported and Will try support it and look after V1.0. No plans using own server for save game integration between systems and platforms supported.
As I said its different than hiscore.... Then nothing problem with own server.