Jump to content
Eternal Lands Official Forums
Sign in to follow this  
Roja

Make A Book Open Up With Nice Gfx!

Recommended Posts

I'd like to make 2 types of books happen in the game as explained below:

 

First type of book--Normal Book

 

-Player clicks with use icon on a book in the game.

-book opens up with a nice book graphic as the background, and text lined up nicely on the pages. You'd be able to click on "Next" or "Back" at the corners of the pages, and even have a page index at the bottom(like Page 1, 2, 3, 4,.....40, 41, ....60; so you can easily go back to a page).

-The text should NOT be limited here.

 

No flags need to be set for this, I believe it can all be done on the client, right? The text can be saved in a special file on the client's side. IT doens't matter if people read it like that if they really want to, these would be just regular books to read. If they are used in quests then info from the book would be required to complete the quest(which the user would have to figure out on their own).

 

The def file would be something like this:

 

Object ID: 1

Map ID: 2

Text input: type here

 

--------------------------------------------------------------------

 

Second type of book--important quest info.

 

This type of book would require that the text be on the server, so that people cannot read it from their harddrive. The text for these books would be small however, as they would mostly be things like notes or clues. So it can have a limited character input.

Share this post


Link to post
Share on other sites

Do you want the book to be self-wrapping or should the editors specify the pages themselves?

 

You could of course have different colours in the text if that's needed.

Share this post


Link to post
Share on other sites

I was thinking about that Wytter...I think self-wrapping is the best, UNLESS you define a new page in there? Like:

 

"let's pretend this sentence takes up 3.5 pages of text." Now, maybe I want to put that extra .5 on a new page to start a new chapter or something. So some command would be stuck in there like this:

 

"let's pretend this sentence takes up 3.5 [new page] pages of text."

 

Does that make sense? :D So by default it would wrap continuously. BUT if you specify with a command that you want a new page, then the text from that point on would go on the new page.

Share this post


Link to post
Share on other sites

Oh I just thought of one more thing. We will need 2 graphics & type setting styles:

 

1. Open book (with text set up on each page)

2. Piece of paper, like a note (text set up in the CENTER of the screen).

 

I will make both these graphics when I get home. Since we can only use squares, you will have to stretch the graphics so they look like a rectangular book and piece of paper :D

Share this post


Link to post
Share on other sites

I made the wrapping function for the rules, that one can be reused generically.

char ** get_lines(char * str, int chars_per_line);//Doesn't free the initial string, terminated by a (char*)0x0.

 

Don't think there's a need to really hurry on this. Will get the artwork later today hopefully, then let's see...

Share this post


Link to post
Share on other sites

OK, did some work on this today. Here's how I implemented the xml-book format:

<book type="1" title="Cry me a river">
        <page>
                    <title></title>
                    <author></author>
                    <text></text>
                    <image></image>
                    <text></text>
                    <title></title>
                    <text></text>
        </page>
        ...
        <page>
        </page>
</book>

 

Basically the idea is that it will only switch page if you specify that it has to. Otherwise it'll auto-wrap and automatically change the page.

Edited by Wytter

Share this post


Link to post
Share on other sites

hey would autowrap be able to be use with encycpedia so when like teh banned 0n3na or some one else will work on it would not has make sure each line does go over the window limit.

 

Or was going whole encycpedia window look like it is in a book.

Share this post


Link to post
Share on other sites

Yes, but not now. It would take too long to rewrite the encyclopedia to support this, so we can't do it for this release...

Share this post


Link to post
Share on other sites
Yes, but not now. It would take too long to rewrite the encyclopedia to support this, so we can't do it for this release...

oh yea silly me forgot books you just go next or pervous or close it does not need links.(my bad) ;)

Edited by jamesvm

Share this post


Link to post
Share on other sites

So, Roja - how do you want the book interface to be like?

 

I was thinking of having a list of the 10 last books (reset on startup), and if you click one of them they would be displayed in a new window. You would be able to have more books open at the same time as well...

 

And how do you want the scrolling between pages to be like? You can't have all pages at the bottom... I could make it possible to go from -5->+5 pages, but if it's more than that it'd most likely look bad...

Edited by Wytter

Share this post


Link to post
Share on other sites

Can we have up to 10 pages listed at the bottom? You'd click the arrows and then it'd start moving to the next pages. I'd rather the pages be below the book graphic, not on the actual pages. The reason why I want as many pages listed as possible is if there is a long book, it'd be a pain in the ass to click through all the pages to get back to where you were.

 

The books will only be available to read in the library. Unless it's a book that you can find and keep in your inventory. In that case when you click to use it in your inv. the book screen will open.

Share this post


Link to post
Share on other sites

http://wytter.tfm.ro/elc/pics/book.jpg

 

It will list the next x*(pages viewed per window) if they are valid. This means that in this particular book you can jump up to 8 pages forward. This is a fairly nice interface and I think it suffices to be able to go max 8 pages back/forth.

 

For the paper I'll check how many pages it's possible to view. Shouldn't be a problem to go 5 pages back and forth.

 

The above book is 65 pages long. Without adding pictures or any other lineups etc. it required the following code:

 

<?xml version="1.0" encoding="utf8"?>
<book title="The rise and fall of Sedicolis" id="1" type="2">
<page>
 <text>Founded on the lush green coastal plain of the northern sea, the town remained a small agricultural society for many years. Than one day, to allow swift movement of his legions, emperor Scylla IV ordered the construction of a road network, connecting the major cities in his realm. The empire long since crumbled, it's cities ruined by the ages or the undead hordes that roamed the land during the Late Era of Diamonds. All was lost, but the roads remained. The elves closed the gates of their cities, the dwarves fled in their mountain strongholds, and humans were left to die. And many did, in ways saturated with unspeakable horror. And when enough corpses had nurtured the hungry earth, the Age of Darkness passed at last and light returned to the realm. The Surviving towns were mostly rather small, and as such the managed to escaped the initial attention of the hordes. Because of this, they provided the impetus to the ravished economy of that time, feeding the ruined cities with their excess agricultural produce. Sedicolis was such a place, and being connected to one of the older Imperial Roads, it was invaluable for travellers and traders. Sedicolis started its rise to glory as a resting place for traders heading from the inland to the coastal ports, the town offered shelter and supplies to weary travellers.

Pilgrims had a particular fondness of Sedicolis, since it was the guardian town of the sacred Cave of Merciful Tears, in which a shrine for Aluwen has been for as long as people can remember. In fact according to the foundation myth of the city, the area where the town is located now used to be a barren desert. Until one day a group of settlers build their farmstead in the middle of the lifeless sands. The people from other towns considered them to be dangerously suicidal fools, with a misplaced trust in Aluwen. Yet, even though the soil was barren and infertile with the salts of the desert, the few people starting planting crops in the lifeless ground, convinced that Aluwen would help them. Every night they prayed to the Goddess, but their prayers could not save their cattle. Not that much later the children became ill from the harsh desert climate, and one by one they shrivelled away before the eyes of their parents. Still the settlers maintained their faith in Aluwen, and when finally the settler buried his wife and died on her grave, saying praise to the Goddess, she wept. The tears of Aluwen rained down on the wasteland, and carved a cave for the weary bones of her followers to rest. Since that day, the cave of Merciful Tears provides the region of Sedicolis with sweet water. It is only because of the water of the wells in the cave, that the town could ever survive a single season in the sun. The shrine of Aluwen, situated in a cave near the town, has since than been a place frequented by pilgrims on their way to greater places of worship. The passing crowd entailed a good deal of wealthy traders and travellers, looking for something to ease their mind of the sorrows of the road. Three local inns flourished side by side. Finally the construction of a town wall was commissioned to provide better protection for citizens and guests alike. But stonemasons and builders also brought a force of resident dwarven labourers, eager for drink and games!

One of the innkeepers cleverly exploited the demand he noticed, and commissioned a table for dwarven dice games to be installed. It involved gambling, as amongst dwarves the fun of the game is related to the stakes. Soon the inn provided entertainment of all sorts, catering for every demand and every desire a tired merchant or worn out stonemason could have. After a few days the playing tables weren't frequented by dwarves alone anymore. The chance to win a fortune lead many travellers to loose their cargo to the landlord of the inn. And where dwarves knew restraint, many others knew only despair. Soon the other innkeepers saw the great profit involved and followed the leading example. More games were installed to attract travellers. The competition between establishments was fierce and Sedicolis became more popular than ever. The town boomed, but the councillors refused to let any other settle permanently, forcing all to stay in the extended inns, with associated places of play. Even pilgrims lingered, forsaking their pilgrimage and spending their days with sleep, and their nights with debauchery and depravity. And so it came to pass that Aluwens shrine slipped in disrepair, and became the scene for sacrilegious festivals and feasts, where all indulged in every vice known to man. Until one day... A Pilgrim by the name Salmir of Uth traversed the domain of Sedicolis.

The night was stormy, thunder and lightning seemed to be the celestial Heralds of doom. And doom did come, in the most unlikely guise one could possibly have anticipated.

The old, skinny Gnome stood before the gates of Sedicolis and entered slowly, his confusion slowly turning into anguish with every step deeper into the town. The sound of his worn deerskin boots through the soiled and muddy streets of the city died in the Dionysian screams and songs that echoed through the narrow alleys. His loyal pet squirrel scurried under a porch, nervously looking back at its master with beady eyes. The door of the 'Rat and the Snake Eye' squeaked open, its saddening chirp usurped by the loud cheers of the drunken mob inside. Salmir remained motionless in the open door, and stared inside with blank eyes. The Squirrel hiding behind his ankle, suddenly decided to climb up the gnomish robes, and settle on Salmirs shoulder. It pressed it's furry little body against the cheek of the pilgrim, as if it knew it would be safe there. Salmir quietly took his pipe, and lit it. He inhaled firmly and exhaled the strong, pungent smell of Gnomish Greenleaf, in one puffy cloud of smoke. He understood all to well what had happened to the city, for his ears were not deaf to the stories told by travellers. Many Pilgrims shunned Sedicolis, for the pleasures of the game and the ecstasy of the flesh can make even the most devout follower turn his eyes away from the celestial deities. Salmir approached the table where the innkeeper was seated on a richly decorated cedar wood couch with lavish crimson pillows, stained by the grease of roasted meat and carelessly spilled wine.

"you rival the glory of the king, innkeeper. But can you also provide me with a quiet room for the night, for I must say my praise. Tomorrow I shall see the Cave of Merciful Tears bow to the Shrine of the White Lady. By high noon I shall be on my way to the greater Holy Places that lie ahead."

The Innkeeper bared the few rotten teeth he had remaining in a grin. "A pilgrim...and a determined one it seems. It has been a while since we last saw your kind around. A room will cost ye 100 pieces of gold." The gnome knew Sedicolis would be more expensive, but 100 pieces of gold was quite an amount of money for a poor pilgrim. Inns all over provided them with food and shelter for a mere 5 coins, but in Sedicolis the excess had washed away any remaining sense of hospitality. "Ye can wager some coins at the tables, who knows, ye might be lucky and earn yer room. Ye might even like it... I could also loan ye some pieces to get started, after all, ye'r a man of the faith." The innkeeper grinned again, bearing even more rot and a single golden teeth shimmering in the back of his mouth, as a diamond in a cesspool. Nothing was said for several minutes. The innkeeper maintained his chiselled grin, sweat drops dripping from his brow down to his many chins, and for lack of a neck, dangling there for a second, before plummeting down on the cedar wood table at which the King of Lard was seated, wallowing in his depravity. Salmir stared directly at him, and when the silent tension had muted much of the crowd, the small gnome spoke with a surprisingly forceful voice.

"I shall not bend to thy depravity, I shall not denounce my Faith for the empty doctrine of thy games of want and excess. I shall not wallow in self pity and I shall not grow bloated with the putrid lard of Mortos as thou hast! May the White Lady have Mercy on thy souls!!"

The common room turned silent almost immediately. Not the whispering of cards, the ringing of coins, not even the breath of Unolas disturbed the awkward tranquillity of the inn. For seconds the silence dwelled, sticking to the walls like thick snapdragon-syrup, until it suddenly and violently erupted in a roaring burst of ale-infused laughter. Salmir recoiled slightly, he could taste the alcohol in the air they exhaled and felt how the looming weight of corruption had rooted out what little decency remained in their hearts.

The Gnome frowned, and slowly turned his back, heading outside. Tacitly he pondered, for it was not laughter of joy that resounded, but the madness of the doomed. As the Gnomish Pilgrim slowly made his way outside, the crowd behind him continued in their ways.

After wandering outside for a while the old gnome decided he had little option but to either sleep outside or return to the inn and come to some sort of agreement. The night was cold and inhospitable, the sands carried by the strong winds capable of ripping the skin of a careless traveller in a matter of hours. Today was not a good time to camp outside. Carefully Salmir counted the shiny coins in his purse. About one hundred and forty coins remaining. The forty he would have left would take him to his pilgrimage, but would most certainly be insufficient to return to the monastery. He decided that these matters would have to be solved later, since the need for shelter was more pertinent now than ever. He lovingly stroked his squirrel on the back, as if reassuring the small critter before diving in the turmoil once again. The unforgiving storm ripped into the wooden scaffolding of the masons, tearing it apart limb for limb, in a cacophony of breaking wood, falling rock and twisted metal. The storm quickly dissipated the heavy dust cloud, spreading the debris and rubble in the streets of Sedicolis. Salmir sighed and retreated back into the Rat and the Snake-eye. At least the large hearth would provide some warmth and relieve to his old arthritic bones.

When The Pilgrim returned inside, the uneasy silence almost immediately returned to the common room. Every step he took made the dry wooden floor squeak in dismay, the silences between the timber moans seemed to last an eternity. A dwarf was frozen in his drinking motion, his tankard balanced halfway between the table and his widely opened mouth. His eyes dim from anticipation and surprise. Yet, it was not a drinking dwarf that was fixed in the eye of Salmir, it was the bloated ruler on his crimson throne that met his gaze with a grin so wide it looked as if his mouth would yield to the exceptional strain and tear from ear to ear. The Gnome reached out and unceremoniously chucked a pile of gold on the small table next to the cedar couch. The innkeeper relaxed his cramped facial expression into a more natural, somewhat devious smile.

"And what would THAT be...," he spoke, spitting out the words in what could only be described as self-indulgent condescension. He was visibly pleased with himself, and smiled some more. The crowd was still silent as a mouse, a single dwarf struggling with his digestion being the only notable exception. Yet not a soul laughed when the dwarf broke wind, rivalled only by the fury of the raging tempest outside. The innkeeper turned his eyes and threw a mild grin at the flatulent mason, who instinctively flinched and faintly stammered; "oops..sowwy 'bout that..." The innkeeper turned his gaze back to the Gnome, and spoke "Well, I don't know what ye hope to do with a mere one hundred coins here, the price of lodging is 250 gold."

"But it was one hundred only ten minutes ago," the gnome exclaimed in surprise.

"aye, but that was ten minutes ago, on my first offer, in the meantime price has gone up a bit, I have to make a living too ye know!"

Salmir realised he was being had by the greedy toad facing him, and he was quite aware that no appeal to pity or decency would find an ear. However he did not have the gold to pay, and staying outside would almost certainly result in an untimely death. Still, the vicious streak in his smile, betrayed the innkeeper was not done playing yet.

"Ye could of course risk a little wager..."

Salmir expected as much. He realised there wasn't much he could do about it so against all his principles he gently nodded.

"We play the dice, if I win I take all yer gold and ye get out of my face, if I lose ye can stay here for half price, only one hundred and twenty five gold coins! Ye won't get a better deal, pilgrim." The crowd chuckled.

"Very well", Salmir answered dryly. The stakes were hardly fair, but it was clear that he was in no position to barter for a better deal. The Innkeeper laughed loudly and clapped his hands. Almost instantly some servants brought a pair of dice, carved from the finest ivory of real Antemedean Snøtbeast, a very large and rare mammalian predator that dwells in some distant continent, shrouded in darkness and mystery. The burning of the eyes on the dice was clearly the craftwork of the finest dwarvish artisans, every eye a perfect diamond-shaped indentation, with a perfectly smooth and glossed inside, making the black specks catch the flickering light of the hearth in a most playful way, as if it were inlaid with the black gems of the Netherforge itself. Funny how such small things could be so valuable and so significant in the unfolding of history as we know it.

"we play for 17"; the patron said. "Closest to 17 wins the game, if ye get more yer arse is mine. You start by throwing the two dice once, than you can choose to throw an extra die twice." Salmir knew this game, and it was tricky to play since the difference between victory and defeat was always but the width of an elvish eyelash. The patron would start and roll two dice, than he would have to roll two himself. Than both men would get one dice and decide whether or not they would roll it again, adding to the sum that was scored before. The second roll could be made twice, and both would add.

The innkeeper glared and cast his dice; scoring eleven on his initial roll. Salmir silently flung the dice over the table, resulting in a roll of ten. The guests of the inn had stopped their own play and many were standing on their benches and tables in order to get a better view of the ongoing wager between the patron of the house and the gnomish pilgrim. When the second casting came and both man rolled their die, the spectators held their breath. The innkeeper managed to score a five, bringing his total score to sixteen, while Salmir only made a four, limiting his count at fourteen. He had one more chance to make the difference. He held his breath as he threw the cubic piece of Snøtbeast bone, it energetically bounced across the surface of the table before it came to a stop. Salmir was afraid to look. The silence that filled the room was uneasy at best. "We'll increase the stakes and continue", the innkeeper shouted, launching the pieces of smoked ham lodged between his teeth in Salmirs face. Salmir peeked at the die and noticed the two black gems facing up, a draw.

"I have nor gold nor property to add to the stakes at hand," Salmir replied. "All I have left is my faith and I could never put it at stake for it is not for mere mortals to dispose off. Only the White Lady of Mercy holds sway over my faith in her goodness."

The grin of the innkeeper became ever more sardonic. "If ye renounce yer faith ye can stay here for free! Hell, I'll even cook ye some soup!" The guests of the inn laughed an empty laugh. "All ye have to do is curse the name of Aluwen, not a bad deal for a free board it seems to me! Besides, if ye don't I'll have ye kicked out and I'll keep yer gold anyway. If ye don't play, ye lose the game."

Silently the gnome turned his back, walking outside with small, but firm steps, unable and unwilling to renounce his faith. The cold winds brought the icy ocean rain , showering down incessantly on the soaked and shivering pilgrim, seeking refuge under a tree while praying vigorously to Aluwen in praise of her goodness. There he was found by the bakers' wife, half buried under the sandy deposits carried by the wind, his hands clutched together in prayer.

The Merciful Tears turned bitter and bloody in rage, for the strength of Salmirs faith overcame the sloth of those that inherited the fertile soils of the settlers that perished so many years ago. Aluwen's blood is the very blood of the Earth. The waters springing from the sacred cave turned acidic with sulphur, and boiled with the rage of her blood, surfacing all around, scorching the land. Her Breath would no longer bring the seasonal rains. The inhabitants of Sedicolis were punished harshly for their crimes. Within the year, the land was barren, the soil infertile. And so it came to pass, that mans greed and weakness surrendered the town once more to the unforgiving desert it was born in.
            </text>
    </page>
</book>

(the reason why the title lacks the last s is that the window manager needs to support longer window titles, will ensure that later ;-).)

Edited by Wytter

Share this post


Link to post
Share on other sites

erhm..be sure to include © :)

Share this post


Link to post
Share on other sites

All your © are belong to us. ;-) But you can set the author by using the <author> tags :) Will put him on a seperate line on teh first page.

Edited by Wytter

Share this post


Link to post
Share on other sites

OK, did some work on this, and the books are working ~satisfying. I will make them default in CVS and make books.c compile along with the rest.

 

I changed the xml format a little - you cannot specify ID or type there any more, as they are defined server-side.

 

When the client clicks anything that's supposed to open a book, the server will send an OPEN_BOOK followed by an Uint16 specifying the book's ID. If the player doesn't have the book, the client will send a SEND_BOOK followed by an Uint16 specifying the ID of the book and a Uint16 specifying the page.

Then the server will send a READ_BOOK followed by a byte, that specifies if it's either a local or a server-side book. If it's a local book, the local book will be opened, if it's a server-side book, the server will send the first and second page to the client (a server-side page, which does not necissarially have the same length as a client-side page). If you want to read more of the book and you don't have all pages for the book downloaded, you'd press "->" and the next page (or pages) will be requested from the server.

This is done to reduce the server bandwidth usage. Once you have read a book, it will stay in memory in case you need it again.

 

The server-side book format looks like the following:

 

[book]
       book_id: 1
       title: Test book
       type: 1
       [local]
               filename: books/testbook.xml
       [/local]
[/book]

[book]
       book_id: 2
       title: Test book 2
       type: 1
       [server]
               

                       [text]
                               And they went sailing, yea!
                               I walked a mile in your shoes - but htey never fitted me
                       [/text]
                       [image]
                               file: textures/items9.bmp
                               u_1: 0
                               u_2: 1
                               v_1: 1
                               v_2: 0
                               startx: 20
                               starty: 20
                               width: 100
                               height: 100
                               text: this is a picture of their swamp
                       [/image]
               
               

                       [text]
                               This is a special test...
                       [/text]
                       [text]
                               tetsldksx
                               sadælkasdæ
                               asdlæksadælsad
                               sæadsaældkasd
                               asækdjsaækdjasd
                               askldjksaldjasd
                               Ã¦kasjdlksajdsad
                               Ã¦kasjdælksajda
                               askæjdlækajdskslad
                               Ã¦jasdlksajdlsakjdsad
                               jakldjalksjdsad
                               klasdjlkasjdlksajd
                               Ã¦jasdælkjasdkljsad
                               Ã¦kajsdkælajsdlkasjd
                               Ã¦kajsdkælajsdlkasjd
                               Ã¦kjalkdsjalksdjsa
                               Ã¦jaskdlasjdlkasj
                       [/text]
               
               

                       [text]
                               New text
                       [/text]
               
               

                       [text]
                               The end.
                       [/text]
               
       [/server]
[/book]

In case you're wondering, the above is written using EML. We don't want other libs than SDL_net server-side, so I wrote a parser for the Entropy Markup Language instead. It's also a lot more lightweight than xml - the parser itself is only ~350 lines :)

Share this post


Link to post
Share on other sites

Hi Wytter,

 

Yes, but not now. It would take too long to rewrite the encyclopedia to support this, so we can't do it for this release...

it is important for me to know what question you answered here before I start working on the encyclopedia. Does that mean "yes, automatic wrapping can be used in the e. later on" or "yes, e. will appear just like a normal book (maybe larger) one day". Is someone else already working on e.?

 

In addition, I planned some advanced wrapping features like automatic interword/interletter space stretching for justified aligment. If you want me I'll write these functions a little more generic so that they can be used for book display as well.

 

With regards

Lachesis

Share this post


Link to post
Share on other sites

it is important for me to know what question you answered here before I start working on the encyclopedia. Does that mean "yes, automatic wrapping can be used in the e. later on" or "yes, e. will appear just like a normal book (maybe larger) one day". Is someone else already working on e.?

It means yes, automatic wrapping can be used in the e. later on. To my knowledge, noone is working on the e. currently.

 

In addition, I planned some advanced wrapping features like automatic interword/interletter space stretching for justified aligment. If you want me I'll write these functions a little more generic so that they can be used for book display as well.

That would be great, my functions are very basic so it'd be good to have some more advanced ones :D

Share this post


Link to post
Share on other sites

The books in CVS should be done now. We'll update the test server to support these soon :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×