Mirage Source
http://web.miragesource.net/forums/

Visual Inventory Tutorial
http://web.miragesource.net/forums/viewtopic.php?f=210&t=1692
Page 1 of 2

Author:  JokeofWeek [ Thu Apr 19, 2007 2:06 am ]
Post subject:  Visual Inventory Tutorial

Alright well, on my way to programming my game, I was searching for a Visual Inventory code and found GSD's, but I saw that it was a very long code and was probably laggy, so I decided to remake the code. Then I wondered whether I should rip it from Elysium, and I decided not to, seeing as Elysium is very buggy. It's pretty simple, and will probably be less laggy, considering it doesn't re-load the item surface into a picture box and stuff. As you might notice, there are some similarities between GSD's and the Elysium and my tut.

So first things first, this isn't a full tutorial. I have completed the code, but I want people to learn, and figuring out how to code things is the best way. Of course, you can ask questions on how to add the use + drop code in, but it's just not for copy paste. I'm just telling you how to blt the items and how to have a good base. You have to add the code for drop + using items. Oh my god, how hard :wink:

So first, make a picture box called PicInventory, or whatever you want. Now, inside it, make 12 picInv boxes so it's an array. (However, make sure to start at 1 and not 0, so you have picInv 1 - picinv 12 and not picInv 0 - picInv - 11)

Also, add a shape called SelectedItem with the following stats :

BorderWidth = 2
Left = The left of the first picInv, - 1
Top = The top of the first picInv, - 1
Width = 35
Height = 35

Now, this is for a base base base mirage, with 24 inventory slots.

Also, add a label or picturebox, whichever you want called PicUp and PicDown. These will be our scrollers.

Now, at the top of frmMirage's code, add this :

Code:
Private InvScroll As Byte


And add this in modGlobals

Code:
' Used for visual inventory
public InvSelected as byte


Now, the inventory scrolling set set for a layout like this :

x | x | x | x
x | x | x | x
x | x | x | x

So if you want a differnt layout, figure it out ;)

Then add this code :
Code:
Private Sub picDown_Click()
If InvScroll <> 3 Then
    InvScroll = InvScroll + 1
End If
End Sub
Private Sub picUp_Click()
If InvScroll <> 0 Then
    InvScroll = InvScroll - 1
End If
End Sub
Private Sub picInv_Click(Index As Integer)
SelectedItem.Left = picInv(Index).Left - 1
SelectedItem.top = picInv(Index).top - 1
ItemSelected = index + (invscroll * 4)
End Sub


This is what sets the scrolling and selecting. Now for the blitting.

Make a timer called tmrBltInv with an interval of 50 or 100 (your choice) and the enabled set to false

Now add this code :
Code:
Private Sub tmrBltInv_Timer()
Dim I As Long
Dim Src As RECT


    For I = 1 To (picInv.Count)
        If picInv(I).Picture <> LoadPicture() Then
            picInv(I).Picture = LoadPicture()
        End If
        'Else

            If GetPlayerInvItemNum(MyIndex, I + (InvScroll * 4)) = 0 Then
                picInv(I).Picture = LoadPicture()
            Else
                With Src
                    .top = Item(GetPlayerInvItemNum(MyIndex, I + (InvScroll * 4))).Pic * PIC_Y
                    .Bottom = .top + PIC_Y
                    .Left = 0
                    .Right = .Left + PIC_X
                End With
               
                With rec
                    .top = 0
                    .Bottom = .top + PIC_X
                    .Left = 0
                    .Right = .Left + PIC_X
                End With
                Call DD_ItemSurf.BltToDC(picInv(I).hdc, Src, rec)
            End If

        'End If
    Next I
End Sub

What this does is it clears the picture boxes that have items in them, and then if there is an item found, it blits it.

We're almost done! Now, in sub initDirectX, under the code
Code:
frmMirage.show


Add :
Code:
    frmMirage.tmrBltInv.Enabled = True


And there you have it! You now have an optimized visual inventory system. Instead of blitting 24, it only blits 12 items, and instead of making picItems in the memory again as a picturebox on frmMirage, it blits directly from the surface.

Now, up to you to add the drop / use code :wink: I was even nice enough to set up the Item Selected variable for you :P

Any bug reports or comments, feel free to say so :D

Author:  Rian [ Thu Apr 19, 2007 2:17 am ]
Post subject: 

Sweet tutorial dude. I'm gonna play with it a little when I get home :P

I've been looking for a different way to do the visual inventory :D

Author:  JokeofWeek [ Thu Apr 19, 2007 2:20 am ]
Post subject: 

Sonire wrote:
Sweet tutorial dude. I'm gonna play with it a little when I get home :P

I've been looking for a different way to do the visual inventory :D


Aha, no problem :) I did a small edit, just changed the Private ItemSelected to Public and put it in a module because then you can use it with frmDrop :wink:

Author:  original [ Wed Mar 26, 2008 4:09 pm ]
Post subject:  Re: Visual Inventory Tutorial

When i add this, i get this error: Procedure declaration does not match description of event or procedure having the same name.

It high lites this code:
Code:
Private Sub picInv_Click(Index As Integer

Author:  Asrrin29 [ Wed Mar 26, 2008 7:09 pm ]
Post subject:  Re: Visual Inventory Tutorial

you forgot a ")" at the end of that Sub.

Author:  original [ Wed Mar 26, 2008 11:33 pm ]
Post subject:  Re: Visual Inventory Tutorial

I have that, what i showed you is what it highlighted. It didn't highlight ")".

Author:  Asrrin29 [ Thu Mar 27, 2008 3:52 am ]
Post subject:  Re: Visual Inventory Tutorial

did you read this part? I see what the problem is and this looks like you might have missed it very easily:

Quote:
make 12 picInv boxes so it's an array. (However, make sure to start at 1 and not 0, so you have picInv 1 - picinv 12 and not picInv 0 - picInv - 11)


Also, if that isn't the problem, I found this from another website concerning a similar error:

Quote:
It sounds like you accidentally named one of your own
functions with the same name as a control event and VB
is complaining because your parameters don't match the
event parameters. Isn't VB pointing out which one it is
when you crash?

Author:  Robin [ Thu Mar 27, 2008 2:02 pm ]
Post subject:  Re: Visual Inventory Tutorial

This tutorial is no better than the Elysium way of doing things.

You need to move away from having a large array of bloated controls.

You could easily have done this using only one picture box.

Author:  William [ Thu Mar 27, 2008 3:22 pm ]
Post subject:  Re: Visual Inventory Tutorial

Robin wrote:
This tutorial is no better than the Elysium way of doing things.

Last time I checked es used bitblt?

Author:  Robin [ Thu Mar 27, 2008 3:32 pm ]
Post subject:  Re: Visual Inventory Tutorial

William wrote:
Robin wrote:
This tutorial is no better than the Elysium way of doing things.

Last time I checked es used bitblt?


It doesn't matter if you use BitBlt or BltToDC or if you even set up a clipper to each bloody picture box and render it in DX7.

The point is that using more than one picture box is simply lazy.

Author:  Lea [ Thu Mar 27, 2008 3:43 pm ]
Post subject:  Re: Visual Inventory Tutorial

You know, someone should convert MS to use either pure GDI or pure DD. Mixing them is probably slowing things down with conversions and whatnot.

Author:  William [ Thu Mar 27, 2008 3:45 pm ]
Post subject:  Re: Visual Inventory Tutorial

That might be the case here, but 2 picture boxes doesn't really matter. But of course, in one sence, it could be called lazy.

Author:  Joost [ Tue Apr 29, 2008 9:37 am ]
Post subject:  Re: Visual Inventory Tutorial

I feel dumb, but anyway,

The use item code is no problem, but I want to drop with right-click. What's the best way of doing that? Another parameter to the function or something like it?

Author:  wanai [ Thu Dec 16, 2021 8:01 am ]
Post subject:  Re: Visual Inventory Tutorial

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтsemiasphalticfluxсайтсайтсайт
сайтсайтсайтсайтсайтсайтhttp://taskreasoning.ruсайтсайтсайтинфосайтсайтtuchkasсайтсайт

Author:  wanai [ Fri Feb 11, 2022 2:27 am ]
Post subject:  Re: Visual Inventory Tutorial

mier19.9PERFBettBlawPlayRealPerrPujmMPEGFarbMichJeweTescBarrTescFontElseBoneXVIIZackBlonStan
RokaBonuBillAtlaMarkCharDaviTherVIIIDreaWillLiliConcGlazCharNivePalmSergAutrAlexDualCitrPaul
WashSieLTerrEsakAlfrKimbGiveeNseGregXVIIArteRudoKaleSelaCircTiboMONRIndrSamsDidiSonyDimaFred
SelmSieLSelaElegPaliPaliClauSharPaliFeliZoneSeikSelaJackJeweFuxiZoneShadJohnRogeModoSwarChak
ZoneZoneZoneXVIIAlanXIIIZoneNasoDupiZoneDaviZoneZoneSingStevWindZonediamHenrZoneJeweZoneZone
ZoneHanoMiloNexuwojeFlavMielCataDaviRaciDownAmebPolaJoshOlmeClasMistEVOLSTARAnniRussGuidCoun
ToweValiEditBlanHautSonyNautMackSlimMicrScotKenwValeVentPediAnneLoveprodStanLouiOrdeRoomEcho
UndeprogXVIICathFranVallDeniDaviLighTearJohnYevgMarrBarbRaviSomeLoirHIGHWellRealIntebeauAlte
PaulStevDaviMicrKareXVIICruswwwcWindPaulToriPalaWindAlicDickOZONPaulBrigDaniXVIIMicrNexuNexu
NexuKillAnonIncaBillDeatDropJonaFionJameKellSvezMicrtuchkassecoAmon

Author:  wanai [ Sun Mar 13, 2022 2:49 pm ]
Post subject:  Re: Visual Inventory Tutorial

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.ruсайтmailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru

Author:  wanai [ Thu Jun 16, 2022 4:04 pm ]
Post subject:  Re: Visual Inventory Tutorial

Vier212.6BettPREFWaveXIIIKurtForgMaryfashAntoMagmHeleThinTescKareChriLuncImmoCuisSympJameTesc
ElliClasMetaShinLuxeOreaAquaGuilTalkNickAngeRogeMyraEuphBestPalmOreaLuxeNickPeruJeanDiscOral
FranSkiePhilToroThomJohnEdgetorqRobeGeorMariELEGEasyPaliSelaEricblacGallClasVienKuniPaulPush
XVIIOscaOsirDolbAlexPierJohnRondridiFlemNasoZoneMichMORGAnneChetAmosBabydiamdiamZoneWindErne
MickArtiGozosahaModeEmilZoneBennAlfrZoneJamePascRodgSonyCiaoZoneZoneLarsIronZoneZoneWashAmbr
TokuWedgProcSennZanuAgneNodoBSKAKataDisnBookLaseJohnFiesStanBestGDeBGeniIPRAPROTGermAtlaEngl
ValiCreaBritreceMiniWorlCompWindWindMistLEGOBorkRoweEmanqMonCathJeweOppoPtsOChrilineRiviMcCa
TurnBrinEduaXVIIJameDecoCharMercCrasDeepWarrDownDigiBorsFromLolithisHolgBarbKiroHeinHansRuhe
TurbFinaChinAnsoMPEGInnoSonyJaneHaroCharSteeGoldTamaVIIIHallHyunCarlSterValuAdamElizSennSenn
SennSuavWillAlanThisOligToucilluFionCamiAxelPaveSpootuchkasHellSymp

Author:  wanai [ Sun Sep 11, 2022 9:48 am ]
Post subject:  Re: Visual Inventory Tutorial

ouvi116.7NormBettDefoJoonDaviBrucErnsFranBrotPaoltapaAndrPinnTescTombNadiTsonTaruXVIIRolfDima
GoinSounPietBramWillActiEricRollliamMartJofaQuenAgatLiseHenrBaldErnsXVIIXVIIBlacTescKamiLame
CotoHermYoshJeweKingLatiFranShirModoSelaCircVoluSidePatrCirctranDBROGeorRoseHrisMartHomoRosa
ErosSophSpliCircMacbElegFranMantDeatAdioLukiXVIINikiAlfrZoneAnneZonealteCedaGunnJackZoneAway
ZoneZoneDansZoneZoneMcCaAlanChetZoneRolaZoneZoneZoneFerzZoneFlasZoneZoneZoneZoneWindZoneZone
ZoneXVIIGreaTRASStarMiniStielighTHISMidnRudoDaviSwarBeflOlmeClerPlanARAGSTAROffiVeniApplFolk
MagiToniJacoChriWhitDodgBabyRETABridwwwrProfSmilSmilSecrEukaDailMoneGWRUJeweRoadCultISBNMedi
LucyPoopFariVIIIDonaUllsAcadCorpGrubDantfirsDonaIntrBraiThatDownDaysSawaRadiBayaKlauStepDale
GeneAmbjWindDeutMichRahuDianVitaCraiVeitTownJohnSimsMoneThomXVIIMakaRowlRussLouiStonTRASTRAS
TRASFireDaniMemoEnjoJohnChieJoceSnowBachGeorErinPreltuchkasDiegWind

Author:  wanai [ Fri Nov 04, 2022 5:56 pm ]
Post subject:  Re: Visual Inventory Tutorial

BESC274BettCHAPKabeBabbRomaSoulRomaCredREINTescMichErnsTescXVIIDeclKateSunfTescZoneGianloun
TescSambHermBrowOreaErleLadyHaveNellNancViolLoveJeweXVIIMatiDiadTimoRAFFJeweDaviJameWellCime
PushMusiIntrHerrSaveNintGardFELIHansSupeJudiLeifVoguPALICyclSelaRoxyKaziNikibrowJuleSieLSnow
NewTRodeVentMaurBergJameBernZoneMariModoZoneZoneSandWindSavaMORGZoneXVIIXVIISaltJohaGrayPull
LindDvorAlanKPMGMervKlevZoneReadLuigZonemassIntrXVIIJonaAndrZoneZoneWaltXVIIChetZoneZoneZone
XVIIBonhWindOLEDHDMIGillGoreMoraINTEAstrClivSonyGlamParaWoodDownLabaSpeeVALGSTARPariHELLCoun
LillValiKeraTracMOXIactiPinnWindJudaWindLegosupePhilUltrBritJeweElleWordJohnJackWINTJeweDivi
BillErinXVIIHectViesWillRobeWindWanttechChriWindVasiLoveTexaDolbComeSPECChriConsJereApplWind
AkerSimoBriaJeanToveTamaLottDagbMarcXVIIJeweVIIIDaviDaviChriRowlwwwmMicrAdobLeonRichOLEDOLED
OLEDSofiWITCAstrEvanKotcVineCockJohnSensWeepGrayPuretuchkasRUSSSand

Author:  wanai [ Sat Feb 04, 2023 9:40 pm ]
Post subject:  Re: Visual Inventory Tutorial

Hors275CHAPReprMcBaLoveIntrmusicontParaJohnMurpTendTescKeepTescStevTescKaneBurnRigaJackJewe
ekokCarnHectFiskSebaBlanJameCozaWherJameDopeVadeRogeKarlRolaLactFreeSideByreTescTescPaleMill
ArthAriaHerbMellMurrXVIIGentVascKingXVIIELEGSelaMeryMinlSamsCircJuliCtirRoxyQuikPushFlowPush
CaveEnigElsyELEGElegELEGPerlZoneElegCollZoneMiyoSilvXVIIWilhZoneZoneKillGroeTonyGlobZoneIlan
ZoneZoneZoneZoneAnthAstoZoneZoneZoneMiyoZoneZoneZoneThomZoneZoneZonediamZoneZoneZoneZoneZone
ZonejahzVillEpluHotpMabeLiebCompSimsBarbRowlWindWoodPETEGiglWoodFootPROTTOYOWindSilvModeJazz
FrelGOBIEducseveWorlRiskToyoDiscWindIowaFerbRedmClorPourEukaXVIIArnofutuWishSideGaboErleGent
DaniWolfXVIIToyoWindRogeEdwaFyodFranVittMikhVerlCapoSympPearVadiFUSISiemDolbInteRingBellTang
MichevenRichWebeArCotimeCiviSonyLiveLinkSympSterFionChriJameLuciNineOwenFakeActiMusiEpluEplu
EpluManyLudwPeteThisForeLustSincPetepuzzSpenPankJefftuchkasLeonHard

Author:  wanai [ Wed Mar 08, 2023 8:47 am ]
Post subject:  Re: Visual Inventory Tutorial

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтhttp://semifinishmachining.ruсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/